<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> 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>
<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> ```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
<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>
<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]
<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>
<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> > 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
<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>
<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>
<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
<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