RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <dscottboggs_gitlab> I'm gonna be honest @Blacksmoke16, I don't like it.
<FromGitter> <dscottboggs_gitlab> like... I'm really big on really readable, almost-plain-english code, only taking shortcuts for like operators and `def` and stuff, just to avoid having to type so much. but this has to be the ugliest way of writing this that crystal supports: `field! email : String, annotations: ["@[CrSerializer::Options(expose: true)]", "@[Assert::NotBlank]", "@[Assert::Email(mode:
<FromGitter> ... CrSerializer::Assertions::EmailValidationMode::HTML5)]"]` Why not use some annotations and some regular macro DSL?
<FromGitter> <dscottboggs_gitlab> why not `athena_field! email : String, options: { expose: true }, blank: false, email: CrSerializer::Validation.new mode: CrSerializer::Assertions::EmailValidationMode::HTML5` or something like that?
<FromGitter> <dscottboggs_gitlab> you could still validate types because NamedTuples are known at compile time, but without putting annotations inside string literals
<devil_tux> @Blacksmoke16: ah, I see, ty. Doesn't make much sense tho, the previous (my) example would clarify the code, while the snippet you provided does not help 2much.
<FromGitter> <dscottboggs_gitlab> sorry I'm not trying to be mean, just give some constructive criticism.
<FromGitter> <dscottboggs_gitlab> @devil_tux, your example is shorter, and maybe it could be added at some point, depending on how complicated it would be to parse that, but I wouldn't agree that it's clearer.
<devil_tux> thats always subjective, although I'd prefer it over blacksmokes example
<FromGitter> <dscottboggs_gitlab> ¯\_(ツ)_/¯ raise an issue?
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab https://github.com/crystal-lang/crystal/issues/7473
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
Dreamer3 has quit [Quit: Computer has gone to sleep.]
Dreamer3 has joined #crystal-lang
devil_tux has quit [Read error: Connection reset by peer]
commavir has joined #crystal-lang
<FromGitter> <mortezaKcode> some one tell me when they want to do some things about windows ? we should wait for 2025 ?
<FromGitter> <Blacksmoke16> its slow but steady progress, https://github.com/crystal-lang/crystal/issues/5430
<FromGitter> <Blacksmoke16> PRs are ofc welcome :)
<FromGitter> <dscottboggs_gitlab> I have found myself, given the choice that crystal provides, preferring this syntax ⏎ ⏎ ```some_method(with_arg: value).method_on(return: value).another_in("a chain")``` ⏎ ⏎ Does anyone have any strong opinions on the use of this syntax style? [https://gitter.im/crystal-lang/crystal?at=5c6f652e7667931e2fdea898]
<FromGitter> <Blacksmoke16> :thinking:
bobmolson[m] has joined #crystal-lang
<FromGitter> <girng> @j8r i have to use floats cause i use a delta in game loop with hp regen
<FromGitter> <sam0x17> pending windows support, does anyone have any recommendations for the best way to package a crystal app for running on windows in a self-contained way? The ideal solution would create an all-in-one .exe file that runs a docker container, but I have only been able to find integrated non-root solutions like this on unix-based systems (e.g. udocker). But yeah manually running in docker seems to be the best way
<FromGitter> ... atm, just curious if someone knows of anything else
<FromGitter> <j8r> @girng as I said before, why not doing like LoL or Dota, using high HP like 10_000? You aren't going to show the floats to the user anyway?
<FromGitter> <j8r> Or @sam0x17 you can run on cygwin or WSL. AFAIK there are projects using cygwin to package Linux apps
<FromGitter> <j8r> I've seen this project on HN http://www.kylheku.com/cygnal/
<FromGitter> <girng> https://play.crystal-lang.org/#/r/6bzw i'm not sure if this is possible, but could i override the to_json and just put the properties in a string and return it? i'm not sure how to go about doing it
<FromGitter> <mavu> I have this function signature that I want to use with the ffi: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ How would my fun line look like, especially considering the char **attributes array? [https://gitter.im/crystal-lang/crystal?at=5c6fbbcb00aa630d9af207ba]
<FromGitter> <mavu> currently I have this: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ But I don't think this is right? [https://gitter.im/crystal-lang/crystal?at=5c6fbc1ea378ef11f61ed3c1]
<FromGitter> <mavu> ```code paste, see link``` ⏎ ⏎ maybe this? But what would I give this function as arguments when calling from crystal? ⏎ Do I literally make an array of pointers to strings and pass a pointer to that? [https://gitter.im/crystal-lang/crystal?at=5c6fbe1ec4da4a11f597a52b]
f1refly has joined #crystal-lang
<FromGitter> <rumenzu> Hi! Is there any Crystal meetups planned around Belgium in 2019 ?
<f1refly> Hello. Is it possible to implement starttls with crystal? If I understand this right, I have to create a tcp socket, negotiate the ssl parameters and then wrap it in an ssl socket.
<f1refly> But I don't have any experience with this, so if someone could tell me if it'll work I'd be very grateful
<f1refly> rumenzu: I believe every event is listed in the official calendar https://calendar.google.com/calendar/ical/0s0pa4k3fov71e4itn79atlmeg@group.calendar.google.com/public/basic.ics
<FromGitter> <rumenzu> f1refly: thank you!
f1refly has quit [Ping timeout: 255 seconds]
f1refly has joined #crystal-lang
<FromGitter> <straight-shoota> f1refly: starttls should work as you described it
ashirase has quit [Ping timeout: 268 seconds]
<FromGitter> <straight-shoota> To initiate the SSL session, just wrap the TCP io in `OpenSSL::SSL::Socket::Client` and use that wrapper for further io operations
ashirase has joined #crystal-lang
<f1refly> Okay, thank you. I just wanted to make sure before spending time on something that won't work anyways
early has quit [Quit: Leaving]
<jokke> straight-shoota: are you sure it's CRYSTAL_PATH?
early has joined #crystal-lang
<FromGitter> <straight-shoota> Yes. You can check it with `crystal env`
<jokke> yeah
<jokke> but src isn't listed there
<jokke> CRYSTAL_PATH="lib:/usr/lib/crystal"
<jokke> lucky also has a tasks folder (also outside src)
<jokke> i don't know how they do it...
<jokke> any lucky devs here?
<mps> straight-shoota: have you seen my message from last night with result of building Crystal on Alpine
<FromGitter> <straight-shoota> mps, yes but didn't have time to look into it
<FromGitter> <straight-shoota> jokke, yes `src` is always looked up. CRYSTAL_PATH contains only additional locations
<mps> ok, sorry for disturbing you. just wanted to know if i have to resend it.
<FromGitter> <mavu> ```code paste, see link``` ⏎ ⏎ How do I make a return value of a Proc void? [https://gitter.im/crystal-lang/crystal?at=5c6fd1fcc82c68509e19bebe]
<jokke> hm
<jokke> straight-shoota: is it possible to set this via shard.yml
<jokke> ?
<FromGitter> <straight-shoota> mps, no worry, all good =)
<FromGitter> <straight-shoota> jokke, no.
<jokke> hm ok
blassin has quit [Ping timeout: 255 seconds]
blassin has joined #crystal-lang
return0e_ has quit [Remote host closed the connection]
return0e has joined #crystal-lang
jemc has joined #crystal-lang
<FromGitter> <straight-shoota> mps see https://github.com/crystal-lang/crystal/issues/7476
<mps> straight-shoota: you nailed it.
<mps> I thought it is probably bug in libxml2 and looked at their git repo but didn't found that
<mps> if i understand it, sigfault comes from libxml2?
<FromGitter> <straight-shoota> yes, that's already visible in your callstack
<FromGitter> <straight-shoota> `xmlTextReaderReadOuterXml` is a function from libxml2
<mps> that xmlTextReaderReadOuterXml was the hint for me to try with previous version of libxml2
<mps> but I don't know anything about libxml2 and can tell if this change is bug or not
<FromGitter> <silmanduin66> Hello when i use loop i do like this: ⏎ ⏎ ```counter = 0 ⏎ all_messages.each do |mess| ⏎ #do something with mess and countercounter``` [https://gitter.im/crystal-lang/crystal?at=5c701c12a378ef11f6216808]
<FromGitter> <silmanduin66> Hello when i user loops i always do like this: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ is there a way i can do the same without having to create that counter variable or is it how it should be done ? [https://gitter.im/crystal-lang/crystal?at=5c701c9685b7eb456913ed20]
<z64> thats fine, but if you like: if that is an Enumerable type, you can use `each_with_index` https://crystal-lang.org/api/0.27.2/Enumerable.html#each_with_index(offset=0,&block)-instance-method
<FromGitter> <silmanduin66> oh thanks
<FromGitter> <sam0x17> @j8r thanks I forgot about cygwin
<FromGitter> <silmanduin66> How to i generate an error response to a ```GET``` request in crystal ? ⏎ ⏎ this is a part of my app : ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c702e58ddaa310c89d394f6]
<FromGitter> <silmanduin66> i can't format properly :/
<FromGitter> <silmanduin66> let 's say the user tries to pass ``` -1 ``` as a parameter , how can i generate a negative response ? ( My app is working so far for the positive response )
<FromGitter> <straight-shoota> @silmanduin66 Take a look at Response#respond_with_error
<FromGitter> <straight-shoota> There might be a more specific way for Amber, but I'm not familiar with it.
<FromGitter> <silmanduin66> that's what i needed :-D
<FromGitter> <silmanduin66> its working
<FromGitter> <j8r> (On the graph)
<FromGitter> <mavu> I wonder where those numbers came form
gcds has joined #crystal-lang
<gcds> hey, guys coming back after few years of not using crystal, what is current situation with ide/editor support what is best to use right now?
<FromGitter> <konung> @j8r that seems like a very strange graph. They are comparing specialized web servers to just "crystal"?? For instance `fasthttp` Go library is "tuned for performance" and is 10x times fast than standard Go's `net/http` library. So just seems like a strange way to compare things.
<FromGitter> <konung> @FromIRC I use sublime text, and it has decent Crystal support, syntax highlighting & it will format your code using `crystal --format`. What else are you looking for? I think VSCode has similar support for Crystal as well
<FromGitter> <silmanduin66> i also use sublime text and the package for crystal is installed in a few clicks
<FromGitter> <kinxer> @gcds I use Atom, which works nicely with Crystal. It's less lightweight than Sublime, though.
<FromGitter> <straight-shoota> atom, sublime, vscode all have pretty decent Crystal plugins with AFAIK similar features.
<mps> eh, there are other editors besides vim (:
<FromGitter> <elorest> Unfortunately yes.
<FromGitter> <elorest> Vim also has good crystal support though.
<FromGitter> <girng> https://crystal-lang.org/api/0.27.2/JSON/Builder.html#raw%28string%3AString%29-instance-method
<FromGitter> <girng> > Writes a raw value, considered a scalar, directly into the IO without processing. This is the only method that might lead to invalid JSON being generated, so you must be sure that string contains a valid JSON string.
<FromGitter> <girng> *considered a scalar* what does this mean?
<FromGitter> <straight-shoota> a scalar is essentially a single JSON value
<FromGitter> <straight-shoota> that's every JSON type except array and object
<FromGitter> <girng> ty
<mps> elorest: yes, I'm quite satisfied with vim plugin and don't autocomplete. syntax higlight and compiler is enough for me
<FromGitter> <elorest> I vim auto complete words in my buffer and thats enough for me
<gcds> ech, I will miss IDE coming from jetbrain IDE's will be bit sad
<FromGitter> <elorest> I used ruby mine for a year and went back to vim for ruby. Didn't really miss much.
<FromGitter> <straight-shoota> @konung @j8r That graph is completely meaningless. There's no information on how these results were produced. It's nice to see Crystal mentioned, but this is just a promotional article for µWS.js with no real interest in an objective comparison.
<gcds> havent done much in ruby, but I use phpstorm, clion, datagrip, goland and webstorm like daily so going back to stone age feels bit sad but oh well u cant have all :D
<mps> I use vim for everything and every language I work with, with just few plugins
<mps> and tmux, of course
<FromGitter> <mixflame> sup @elorest
<z64> same; tmux, ctrlp, using `ag` to power project grep.. its the best :) rhysd's vim-crystal commands are nice
<FromGitter> <girng> i'm trying to create a modify_tuple method but not sure how about going about it, progress: https://play.crystal-lang.org/#/r/6c57/edit
<FromGitter> <girng> i am trying to get it to return a new tuple, but with that index (1) changed to 500
<FromGitter> <girng> since they are immutable, i have to create a new one i believe
<FromGitter> <girng> actually, why don't i just use an array?
<FromGitter> <girng> https://play.crystal-lang.org/#/r/6c5p this seems to work
<z64> yes. you would have to return, for example index 1, the equivalent of `{tuple[0], new_value, tuple[1], tuple[2]}`
<FromGitter> <girng> @z64 ohhhhh
<z64> *indexes 2, 3
<FromGitter> <girng> so array's are passed by reference?
<z64> yes
<FromGitter> <girng> tuples passed by value (if i got that right)
<z64> yep. if you're ever not sure, you can look at the top of a types docs https://crystal-lang.org/api/0.27.2/Tuple.html and you will see `Tuple < Value` or https://crystal-lang.org/api/0.27.2/Array.html `Array < Reference`
<z64> something like `Tuple#[]=` could be written that returns a copy, but i think element would likely become a union of every other element, so you'd lose some type information, similar to how `Tuple#map` currently behaves https://play.crystal-lang.org/#/r/6c5u
<FromGitter> <girng> good to know
<FromGitter> <girng> awesome
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <silmanduin66> Can someone help me ? i have an ```undefined method 'to_u64' for Nil (compile-time type is (Int64 | Nil))``` ⏎ ⏎ ```if !value.id.nil? ⏎ target_id = value.id.to_u64 ⏎ else ⏎ # ...``` [https://gitter.im/crystal-lang/crystal?at=5c704bc99e430b3086ad58db]
laaron has joined #crystal-lang
<z64> try `if id = value.id; target_id = id.to_u64`. calling `valud.id` will still return the same (nilable) type
oprypin has quit [Read error: Connection reset by peer]
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
<FromGitter> <silmanduin66> i got a ```undefined method 'id' for Nil```
<FromGitter> <Blacksmoke16> ```if v = value.id ⏎ target_id = v.to_u64 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5c704e85c4da4a11f59b8b5c]
<FromGitter> <Blacksmoke16> try that
<FromGitter> <Blacksmoke16> which should work, but is pretty much what z64 wrote...
<FromGitter> <Blacksmoke16> unless its possible for `value` itself to also be nil?
<FromGitter> <silmanduin66> ok i retried yes
<FromGitter> <silmanduin66> value has possibility to be nil
<FromGitter> <Blacksmoke16> so do something similar but for value
<FromGitter> <Blacksmoke16> like
<FromGitter> <silmanduin66> it's a database query
<FromGitter> <Blacksmoke16> ```if v = value```
<FromGitter> <Blacksmoke16> ```if v = value ⏎ if id = v.id ⏎ target_id = id ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5c704f3ec776985d8f37a508]
<FromGitter> <silmanduin66> it works
<FromGitter> <silmanduin66> ty
gcds has quit [Quit: Page closed]
<FromGitter> <girng> how can you create an array alias for &.read(Type)? ⏎ https://github.com/crystal-lang/crystal-db/blob/master/src/db/query_methods.cr#L198
<FromGitter> <j8r> You could even do `if id = value.try &.id`
<FromGitter> <silmanduin66> oh it also works. Can use is it with value is an array ? ( and test if it is nil or not ? )
<FromGitter> <girng> nvm, just gonna put the entire db.query_all inside its own function and use that. this is actually better because it results in cleaner code
<FromGitter> <j8r> @silmanduin66 yes, `#try` is available for all objects
jemc has quit [Quit: WeeChat 2.2]
laaron- has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
oprypin has joined #crystal-lang
<FromGitter> <girng> how can i create a array of types like a Tuple? `alias ArrayTypes = Tuple(Int32, Int32)`
<FromGitter> <girng> It works for a `Tuple` type, is it possible to do it on an Array type?
<FromGitter> <Blacksmoke16> it would have to be a union of all types
<FromGitter> <Blacksmoke16> that would be in the array
<FromGitter> <Blacksmoke16> since at compile time you dont know what the type of each element in an array would be
<FromGitter> <girng> which reads the types in order...
<FromGitter> <girng> so i have to have the types in the array in the correct order. i also am going to use that that type for a property in a Class to store that info, so i really just want an alias of types in an Array... just like how the Tuple worksnot just to get the data from mysql, but i want to use that same type
<FromGitter> <girng> The only reason why I'm switching to an array is cause it's mutable, this all works fine with a Tuple but i can't modify the values. Well, I could, but would need to create a new tuple each time, etc. It's much easier to modify the values in an array with an index (array[index] = new_value), instead of creating a new tuple, {val1, val2, val3, new_value}, if i wanted to changed to index 3. Array way is way easier
<FromGitter> <girng> Example, `&.read(String)` would be `&.read(ArrayTypes)`. That's what I'm trying to do
<FromGitter> <girng> I am trying to get ArrayTypes to be an alias, so I can use those anywhere
<FromGitter> <girng> wow, so &.read(String) (https://github.com/crystal-lang/crystal-db/blob/master/src/db/query_methods.cr#L198) doesn't return an array of values, it returns 1 array, with a Tuple, and the values are in the tuple. so, when you are doing `&.read(Int32, Int32)` the `typeof` is `Array(Tuple(Int32, Int32))` not `[Int32, Int32]` why? is says specifically *returning an array of the values of the blocks.*
devil_tux has joined #crystal-lang
jemc has joined #crystal-lang
<FromGitter> <Blacksmoke16> let me catch up
<FromGitter> <Blacksmoke16> @girng does the data coming from the db map to a class?
<FromGitter> <Blacksmoke16> you could pretty easily create a simple ORM interface
<FromGitter> <Blacksmoke16> so your db queries return objects