<cerulean>
how long do you think before the mainstream tech picks up crystal?
<cerulean>
i want to do crystal professionally
<crystal-gh>
[crystal] asterite opened pull request #5036: Parser: error on duplicate case when condition (master...feature/case-when-repeated) https://git.io/vdIMf
<FromGitter>
<fridgerator> minimum 2 years
<FromGitter>
<fridgerator> j/k, i dont nkow
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
sp4rrow has joined #crystal-lang
weston1 has quit [Ping timeout: 260 seconds]
weston1 has joined #crystal-lang
<cerulean>
id agree tho
weston1 has quit [Ping timeout: 248 seconds]
snsei has joined #crystal-lang
hightower4 has quit [Ping timeout: 240 seconds]
weston1 has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter>
<GavinRay97> I'm a fullstack React/Vue + Ruby/Rails dev
<FromGitter>
<GavinRay97> been looking at Crystal recently
<FromGitter>
<GavinRay97> how hard would it be to port a Rails API to a Crystal project?
<FromGitter>
<faustinoaq> @GavinRay97 We have been working on Amber, it is very similar to Rails and is in active development, take a look https://amberframework.org/
<FromGitter>
<faustinoaq> Also if you like something minimalist like Sinatra you can try http://kemalcr.com/
weston1 has quit [Ping timeout: 240 seconds]
<FromGitter>
<GavinRay97> @faustinoaq Thanks! I'm looking for the most lightweight API-only setup with simplistic syntax, essentially.
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter>
<faustinoaq> 👍
<FromGitter>
<faustinoaq> Papierkorb, qt5.cr is amazing ✨
<FromGitter>
<bararchy> What's the syntax for method alieas ?
<FromGitter>
<bararchy> or is it only for types ?
<Groogy>
Morning!
<Papierkorb_>
Morning
<Papierkorb_>
bararchy, only type aliases. Method aliases are frowned upon. If you meant a delegator, you can use the delegate macro `delegate foo, bar, baz, to: @something`
<FromGitter>
<bararchy> I just want to have two names for the same method , let's say I have `.destory`, and I want it to respond to `.close` too, and doing ⏎ ⏎ ```def close ⏎ destory ⏎ end``` ⏎ ⏎ is a little ugly [https://gitter.im/crystal-lang/crystal?at=59c9fe93cfeed2eb654ec47f]
mark_66 has joined #crystal-lang
<Groogy>
huh what does the delegate macro do exactly? Not seen that before
<Groogy>
also @bararchy a good question would be why do you want two symbols to correspond to the same functionality?
<FromGitter>
<bararchy> so that I can conform with the original lib, and also the languge standards
<FromGitter>
<bararchy> :)
<Groogy>
#destroy is sometihng I usually associate with resources while #close would be something like IO or a window
<Groogy>
ah
<Yxhuvud>
groogy: it forwards a method call to whatever it delegates to
<Groogy>
so it would forward foo.bar to @something.bar?
<Groogy>
foo.@something.bar
<Papierkorb_>
yes
claudiuinberlin has joined #crystal-lang
<Papierkorb_>
bararchy, it looks ugly because aliases are ugly
<Papierkorb_>
Ruby has been burnt by it, its stdlib is full of aliases. It sucks.
<Yxhuvud>
I kinda like it. YMMV.
<FromGitter>
<bararchy> is there a way I can know if an object is being called from the main Fiber or from another spawn ?
balduin has quit [Remote host closed the connection]
<FromGitter>
<bararchy> So, started working on TensorFlow bindings for Crystal, if anyone want's to join in: https://github.com/NeuraLegion/tensorflow.cr, it's MIT licensed ofc
<FromGitter>
<imonmyown> @bararchy not sure I can be of help, but if I can let me know how
<FromGitter>
<imonmyown> sorry, didn't get to `Contributing` section
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<bararchy> :) @imonmyown you can see what is under development, just pick something you want to add, see the referances, and PR
claudiuinberlin has joined #crystal-lang
<FromGitter>
<imonmyown> Ok, got it :)
rohitpaulk has quit [Ping timeout: 248 seconds]
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
DeBot has quit [Ping timeout: 240 seconds]
cerulean has quit [Ping timeout: 255 seconds]
jhass has quit [Ping timeout: 255 seconds]
asterite has quit [Ping timeout: 252 seconds]
asterite has joined #crystal-lang
jhass has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
voloyev has joined #crystal-lang
voloyev has quit [Quit: WeeChat 1.9.1]
voloyev has joined #crystal-lang
<FromGitter>
<imonmyown> I don't seem to be able to assign to an element of a newly allocated array ⏎ ⏎ ``` prefix = Array(Int32).new(arr.size.as Int) ⏎ prefix[0] = 1``` ⏎ ⏎ Getting Index out of bounds... [https://gitter.im/crystal-lang/crystal?at=59ca1cdbbc4647297477c00d]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Papierkorb_>
As expected. That array is empty. Though your snippet looks like you can #map from it. Otherwise, you can set the initial value to pre-fill the array to the given size.
cerulean has joined #crystal-lang
hightower2 has joined #crystal-lang
<jokke>
i was just playing around with crystal to expose c functions to create dynamic libraries
<jokke>
for c
<jokke>
but i ran into my first problem: crystal redefines main
<jokke>
can i circumvent this?
bmcginty has quit [Ping timeout: 255 seconds]
<jokke>
Papierkorb_: your into this low level stuff, any ideas? :)
bmcginty has joined #crystal-lang
<Papierkorb_>
jokke: It has since been broken, the `empty` prelude began to ship with a `fun main` recently. There's also now way (afaik) to remove a `fun` after defining it somewhere. You can get around this by carefully writing a custom prelude which doesn't `require` anything defining the main()
<Papierkorb_>
Have a look at the real main implementation however, as you'll want to start the garbage collector etc.
<FromGitter>
<asterite> We can probably have a flag to not generate main, for example NO_MAIN. But dynamic libraries are very limited right now. For example `is_a?` won't work well.
<Papierkorb_>
asterite, I think that would be a useful thing to have. Not for the many, but for the some :)
Qchmqs__ has joined #crystal-lang
<Papierkorb_>
No idea about embedded systems, but I can imagine those needing some early configuration before the C code would jump into Crystal-land (and thus, its main)
Qchmqs__ is now known as Qchmqs
<FromGitter>
<bew> Nice gist Papierkorb!
<FromGitter>
<bew> What do you mean by removing a fun after its definition? How?
hightower2 has quit [Ping timeout: 240 seconds]
<Papierkorb_>
bew, there's no`undef_fun` functionality in the language (or the like), which would let you to get rid of the `main()`.
hightower2 has joined #crystal-lang
<Papierkorb_>
Not that I want that feature, a --no-main or `--flag NO_MAIN` would be ideal
<jokke>
yeah that'd be great
<jokke>
and also easy to implement
<Papierkorb_>
custom flags would be kinda neat though *cough*
<jokke>
well you could just use NO_MAIN=1 ...
<FromGitter>
<bew> Oh okay I understood there was a way (you said "there's now way" instead of "no way"! )
<jokke>
and then {% if env("NO_MAIN") %}
<jokke>
or something similar
<FromGitter>
<bew> undef_fun is more interesting than using flags I think
<Papierkorb_>
While possible, I'd prefer an "official" solution. Especially as IMHO it would be a nightmare if the stdlib would rely on such ENV checks
<FromGitter>
<bew> @asterite what is the issue with `is_a?`, do you mean that multiple Crystal libs will have th ossue that 2 different types may have the same type id?
<crystal-gh>
crystal/master 2eca01b Faustino Aguilar: Fix example of hexadecimal sequence (#5032)...
hightower2 has joined #crystal-lang
sz0 has joined #crystal-lang
<FromGitter>
<ziprandom> @sdogruyol hey is there a way to make kemal stop complaining about command line opts it doesn't know?
hightower3 has joined #crystal-lang
<FromGitter>
<bew> For https://github.com/crystal-lang/crystal-book/pull/119 he's trying to merge `master` to `gitbook-3` is it really what should happen? (@asterite @mverzilli) What is this `gitbook-3` branch for?
hightower2 has quit [Ping timeout: 248 seconds]
<FromGitter>
<ziprandom> @sdogruyol found it already ..
<FromGitter>
<mverzilli> good catch! that's a pretty old branch that Brian used to update gitbook deps
<FromGitter>
<mverzilli> I'll kill that branch
<FromGitter>
<mverzilli> thanks @bew !
<59NAA20C1>
[crystal] ysbaddaden closed pull request #4894: Merge SecureRandom into Random and Random::Secure (master...std-merge-secure-random-into-random) https://git.io/v5GtY
<17SAAOSDC>
[crystal] ysbaddaden pushed 3 new commits to master: https://git.io/vdLMW
<17SAAOSDC>
crystal/master 27684db Julien Portalier: Merge SecureRandom into Random and Random::Secure...
<17SAAOSDC>
crystal/master 79d0358 Oleh Prypin: Reimplement random_bytes to be consistent with endianness
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<eliasjpr> Im ordering a set of them :)
<FromGitter>
<bew> @eliasjpr I was thinking about one with big logo on the back (with Crystal written under) (with my pseudo at the top! ^^) on a little <logo + Crystal> on the front left, but those a great start! :p
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Papierkorb_ has quit [Quit: Konversation terminated!]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Qchmqs has quit [Quit: Konversation terminated!]
sp4rrow has joined #crystal-lang
rohitpaulk has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Philpax has quit [Ping timeout: 240 seconds]
claudiuinberlin has joined #crystal-lang
rohitpaulk has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<ansarizafar> If a method name is stored in a variable how can I run it?
<FromGitter>
<bew> you can't
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter>
<jwaldrip> Crystal is not as meta as ruby.
claudiuinberlin has joined #crystal-lang
<FromGitter>
<jwaldrip> @ansarizafar can you provide an example?
<FromGitter>
<ansarizafar> After making an unsuccessful attempts of storing a proc in a Hash without specifying return type. Now I am trying to store a class method in a Hash so that I can later run it. ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=59ca739eb59d55b8233c9a93]
<FromGitter>
<ansarizafar> > After making several unsuccessful attempts of storing a proc in a Hash without specifying return type. Now I am trying to store a class method in a Hash so that I can later run it.
<FromGitter>
<ansarizafar> Like that ⏎ store[key] = User.list
<FromGitter>
<ansarizafar> how can I run list method which is store in a hash
<FromGitter>
<bew> do you need to pass arguments to thoses methods when calling them?
<FromGitter>
<ansarizafar> yes
<FromGitter>
<bew> are they known when you add the method to the hash?
<FromGitter>
<ansarizafar> no
<FromGitter>
<asterite> case key; when "list" then User.list; etc.
<FromGitter>
<ansarizafar> I want to make it generic. Is there any syntax that I can use to run the method stored in has directly.
<FromGitter>
<jwaldrip> Can the proc/method return any type?
<FromGitter>
<ansarizafar> Ideally I would like to store a proc block in has without specifying return type as return type is not known in advance, but I think its not possible.
<FromGitter>
<jwaldrip> If you know what the possible types could be you could store them in a union
<FromGitter>
<jwaldrip> or, let me ask a question... do you expect your method to always return something?
<FromGitter>
<jwaldrip> Or are you just trying to invoke a method that may void?
<FromGitter>
<bew> @ansarizafar do you need the return value?
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<ansarizafar> yes, It could be a NameTuple or an Array Of NamedTuples
<FromGitter>
<jwaldrip> So use a union
<FromGitter>
<ansarizafar> Yes I need return value
<FromGitter>
<jwaldrip> If you know the various return types, just set it up as a union
<FromGitter>
<ansarizafar> Return types are not known in advance. Namedtuple will be generated with the fields return from Postgre Db depending on the query.
<FromGitter>
<Willamin> Hi everyone! I've got an absolutely crazy question for you. I want to reopen the Integer structs and add a macro def that throws a compile time exception based on the value of the Integer. I can't find a definitive list of macro variables such as `@type` and `@def`. Can anyone here help?
<FromGitter>
<bew> throw a compile time error when doing what @Willamin ?
DTZUZU has quit [Quit: WeeChat 1.9]
<FromGitter>
<Willamin> Contrived example: I'd like to add a `.is_this_a_0_at_compile_time` to Integers that throws a compile time error if it's called on a non-zero integer
<FromGitter>
<bew> The syntax you ask is not possible because macros are not methods with a receiver, they're on the class/module/top level, not instance level, but you could have `is_this_a_0_at_compile_time(0)` quite easily
<FromGitter>
<Willamin> @bew even when it's a macro on a literal struct like an Int32?
<oprypin>
eliasjpr, do u have rights to sell Crystal logo?
<FromGitter>
<bew> yes, if you write a macro in `Int32`'s struct, you'll be able to call it as `Int32.my_macro` or just `my_macro` when called in the scope of the `Int32` struct
<Papierkorb>
William, how should the program know at compile-time, which run-time value the integer will have?
<Papierkorb>
Crystal isn't a time machine
<FromGitter>
<bew> \o/
<FromGitter>
<Willamin> hahaha
claudiuinberlin has joined #crystal-lang
<Papierkorb>
A method that takes an integer (or anything) as argument doesn't know if it was passed in as literal or through an variable (or ...), if that's what you mean.
<FromGitter>
<Willamin> I was hoping that I would also be able to tell if the *macro* was called from a literal (eg. `0.is_this_a_0_at_compile_time`) vs called from a variable (eg. `x.is_this_a_0_at_compile_time`),
<Papierkorb>
No, as a macro is state-less, you can't call it like a member method.
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<sdogruyol> how can I check if a value is truthy outside of a guard clause
<Yxhuvud>
What do you want to achieve?
<FromGitter>
<eliasjpr> <oprypin> My apologies was never my intention I will remove
<FromGitter>
<eliasjpr> I just wanted some tees
<FromGitter>
<eliasjpr> <oprypin> removed!
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<jose-rodrigues> What is the LICENSE of the crystal logo?
ShalokShalom_ is now known as ShalokShalom
<crystal-gh>
[crystal] asterite opened pull request #5038: Fix incorrect type of Int#times iterator (master...bug/5019-int-times-type) https://git.io/vdtOl
<oprypin>
eliasjpr, hey it's not my decision either way. but you're supposed to ask permission. see https://crystal-lang.org/media/ bottom of page
<FromGitter>
<eliasjpr> 👌🏻👍🏻 thanks
<oprypin>
jose-rodrigues, see that link too
<FromGitter>
<eliasjpr> I think crystal team should open a store for tees and stuff that would be a nice way to contribute for the crystal cause
<oprypin>
for sure
<FromGitter>
<kazzkiq> Is `Process.run` a blocking method?
<FromGitter>
<kazzkiq> If I run a cURL command via `Proccess.run`, and it takes 10 seconds to return, is my application going to hang for 10 seconds?
<oprypin>
kazzkiq, it's a convenience method that wraps Process.new and Process.wait which blocks the current fiber until the process ends
<oprypin>
also why run a curl command......
<crystal-gh>
[crystal] asterite closed pull request #5038: Fix incorrect type of Int#times iterator (master...bug/5019-int-times-type) https://git.io/vdtOl
<FromGitter>
<kazzkiq> > *<oprypin>** also why run a curl command...... ⏎ Because that's the only way to make Mailgun work with Crystal at the moment
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
sp4rrow has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
<FromGitter>
<crisward> @kazzkiq I have a mailgun client, just not got around to open sourcing it yet. It's actually mailgun and sendgrid. I use `HTTP::Client`. I want to add a wrapper around SMTP with it to, so it's a common api for however you want to send mail.
ylluminate has joined #crystal-lang
snsei has quit [Remote host closed the connection]
sp4rrow has joined #crystal-lang
<FromGitter>
<loloof64> Thanks @codenoid Maybe I'll have to do myself bindings for the functionnalities I need
<oprypin>
kazzkiq, are you sure about that? crystal's http client should (at least strive to) provide all the same functionality. if it doesnt match that expectation, ask for help / report it
<FromGitter>
<loloof64> Thank you also @faustinoaq Maybe Qt binding will be the solution.
<FromGitter>
<faustinoaq> Yeah Qt bindings are awesome! ✨
<FromGitter>
<asterite> When you don't use a constant it's not typed, so a constant can be used as a placeholder in macros
<FromGitter>
<asterite> That is, when you don't use that constant at runtime
<FromGitter>
<asterite> Also known has hack #123 (just kidding)
<FromGitter>
<asterite> But Elixir does something similar, only with attributes (which only exist at compile-time, I think)
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 248 seconds]
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter>
<vonKingsley> is there a way to tell crystal to always use some link-flags, so i don't forget to pass --link-flags -I/usr/local/opt/openssl/include --link-flags -L/usr/local/opt/openssl/lib each time
<FromGitter>
<jose-rodrigues> @vonKingsley I don't know if you can configure crystal for that but you can do a shell alias. Or better a makefile.
hightower3 has quit [Ping timeout: 240 seconds]
<FromGitter>
<vonKingsley> thanks @jose-rodrigues i think ill add it to a shell alias
hightower4 has quit [Ping timeout: 240 seconds]
<FromGitter>
<kazzkiq> @crisward Awesome! Will take a look at it tonight. Thanks!
<FromGitter>
<asterite> You can use @[Link] on LibC
hightower2 has joined #crystal-lang
<FromGitter>
<crisward> @kazzkiq raise an issue if you have any problems. Took me a while to originally get the apis working ok, but pretty sure everything is there now, except the stuff mentioned in the Readme.
<oprypin>
vonKingsley, have u tried `{LD_,}LIBRARY_PATH=/usr/local/opt/openssl/lib crystal run blah`
<oprypin>
in which case, `export {LD_,}LIBRARY_PATH=/usr/local/opt/openssl/lib` in your shell and proceed normally
<FromGitter>
<vonKingsley> @oprypin I originally just tried `LIBRARY_PATH=/usr/local/opt/openssl/lib crystal run` which didn't work for me
<oprypin>
LIBRARY_PATH is for build LD_LIBRARY_PATH is for execution. so have u tried both?
<FromGitter>
<vonKingsley> @oprypin just tried it and it still didn't work for me, still links to openssl 0.9.8
<oprypin>
vonKingsley, how are you checking that? it does not link to any particular openssl
<oprypin>
you must use LD_LIBRARY_PATH when running the resulting binary
<oprypin>
that's when the override happens
<FromGitter>
<vonKingsley> i was checking two ways 1 with otool -L on the binary. and the other was running a wireshark and checking if it was using tls 1.2, trying to troublshoot an tls issue
<oprypin>
ok but did u start those with LD_LIBRARY_PATH
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<vonKingsley> Yeah I tried `LD_LIBRARY_PATH=/usr/local/opt/openssl/lib crystal run tls_test.cr` and it was still using, TLS V1. no worries on it. i got to run but i'll figure something out.
<crystal-gh>
[crystal] MakeNowJust opened pull request #5043: Remove 'macro def' related code from lexer.cr (master...fix/crystal-lexer/follow-remove-macro-def) https://git.io/vdqUL
<FromGitter>
<bew> From the given examples, I don't think intersection type is relevant in Crystal
<FromGitter>
<ezrast> You might want to require that an object's class includes two different modules
<FromGitter>
<bew> oh right
<FromGitter>
<ezrast> I don't know what a real use case would look like though
<FromGitter>
<bew> no idea too
<oprypin>
faustinoaq, what's your use case?
<FromGitter>
<mverzilli> when you're augmenting JS with Flow it makes sense because then you can annotate a param as "whatever you send here should have an attribute X and an attribute Y"
<FromGitter>
<bew> pinging @asterite will maybe bring a little light here
<FromGitter>
<bew> yes @mverzilli that's what I was thinking too
<FromGitter>
<mverzilli> in JS it's common to use ad-hoc objects to sort of gimmick named arguments, for example
<FromGitter>
<mverzilli> Flow is a huge attempt at reverse engineering common patterns of use in JS and type-check them