RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.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
<travis-ci> crystal-lang/crystal#9b32f7d (master - Fix version check for LLVM < 6.0 (#6383)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/409408014
<travis-ci> crystal-lang/crystal#d36a654 (master - replace mapping with serializable in compiler (#6308)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/409409446
<FromGitter> <Blacksmoke16> when using `JSON::Serializable` with not null properties when not including an `initialize` method, you get `instance variable '@name' of Foo was not initialized directly in all of the 'initialize' methods, rendering it nilable. Indirect initialization is not supported.` which wasn't a problem with the JSON.mapping
<FromGitter> <Blacksmoke16> is that intended behavior?
<FromGitter> <bew> With what code?
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
return0e has quit [Ping timeout: 248 seconds]
ma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <delef> @Blacksmoke16 https://play.crystal-lang.org/#/r/4mt7
ma has joined #crystal-lang
<FromGitter> <Blacksmoke16> omg i didnt use `include`
* FromGitter * Blacksmoke16 facepalm
<FromGitter> <Blacksmoke16> thanks @delef
akaiiro has joined #crystal-lang
yaewa has joined #crystal-lang
moei has quit [Ping timeout: 260 seconds]
greengriminal has joined #crystal-lang
akaiiro has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
akaiiro has joined #crystal-lang
akaiiro has quit [Ping timeout: 260 seconds]
Raimondii has joined #crystal-lang
yaewa has quit [Quit: Leaving...]
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
akaiiro has joined #crystal-lang
moei has joined #crystal-lang
renzhi has quit [Quit: WeeChat 2.1]
ma has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ma has joined #crystal-lang
ma has quit [Read error: Connection reset by peer]
alex`` has joined #crystal-lang
renzhi has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 248 seconds]
DTZUZO has quit [Ping timeout: 264 seconds]
renzhi has quit [Ping timeout: 256 seconds]
ashirase has quit [Ping timeout: 260 seconds]
ashirase has joined #crystal-lang
renzhi has joined #crystal-lang
Groogy has joined #crystal-lang
<crystal-gh> [crystal] RX14 closed pull request #6439: Change Foo:Class representation of Class types to Foo.class (master...feature/change-class-string) https://git.io/fN4Aa
renzhi has quit [Ping timeout: 256 seconds]
alex`` has quit [Quit: WeeChat 2.2]
<travis-ci> crystal-lang/crystal#665b18c (master - Change Foo:Class representation of Class types to Foo.class (#6439)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/409487365
renzhi has joined #crystal-lang
<FromGitter> <bararchy> Is there an option to do `getter_all`?
<FromGitter> <bararchy> or maybe do it with a macro somehow
<Groogy> create a getter for all variables?
<Groogy> should be doable in a macro yeahg
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> any idea on how to do it? looking at the docs I don't see anything about instance vars etc..
renzhi has quit [Quit: WeeChat 2.1]
<FromGitter> <bew> It's not possible yet.
<FromGitter> <bew> E.g: https://carc.in/#/r/4mub
<FromGitter> <bew> When the macro expands, the compiler didn't pass on the vars so you can't access them (some other macros could still 1+ i/cvars
<FromGitter> <bew> )
<FromGitter> <bew> still add*
<FromGitter> <bararchy> I see
<FromGitter> <bew> You can only access the ivars from inside a method that has some macro expansion inside
<FromGitter> <bararchy> I guess back to the manual work :)
<FromGitter> <bararchy> thanks @bew
<FromGitter> <bew> Until we have a new macro hook that executes just after i/cvars are fully typed and that still allows you to add methods, this won't be possible..
<FromGitter> <bew> But you just have to write `getter ` before the ivars declarations, so it's not too much manual work, is it?
<FromGitter> <bararchy> yeha, just noticed that line breaks wont effect it, not an actual issue lol :)
<Groogy> yeah though for structs it would be great with a property_all
qijian has joined #crystal-lang
return0e has joined #crystal-lang
qijian has quit [Quit: 离开]
SijmenSchoon[m] has joined #crystal-lang
alex`` has joined #crystal-lang
<Groogy> huh so... when I am doing {{test}} with a code block like this: { puts "Hello" } it becomes expanded as do\nputs "Hello"\nend
<Groogy> which breaks my macro
<Groogy> I find that weird
<Groogy> same if I am using the &.method syntax
<FromGitter> <delef> Crystal has alternative for spread syntax in JS or PHP (`method(...[1, 2, 3])`)? ⏎ https://play.crystal-lang.org/#/r/4mv0
<FromGitter> <delef> or like on Ruby? ⏎ ⏎ ```def go(x, y) ⏎ end ⏎ ⏎ point = [12, 10] ⏎ go(*point)``` [https://gitter.im/crystal-lang/crystal?at=5b5dca1d854add6cee0600b0]
<FromGitter> <delef> I would like to see an example with arrays
<FromGitter> <mikeeus> Hey everyone, I hope its alright to post links to articles here. I just wrote one on uploading and validating images with Lucky (https://dev.to/mikeeus/uploading-and-validating-images-with-crystal-and-lucky-on-heroku-13p2). I used this awesome shard crymagick (https://github.com/imdrasil/crymagick) which made it super easy to validate images. I hope you guys like it, and let me know if I can there are any
<FromGitter> ... topics (web dev related) that you'd like me to write about
<FromGitter> <j8r> I'll work only with tuples
<FromGitter> <j8r> @delef https://play.crystal-lang.org/#/r/4mvf
<FromGitter> <delef> @j8r Yes, I know, but I would like to know if there is something for arrays
Groogy has quit [Ping timeout: 248 seconds]
Groogy has joined #crystal-lang
<FromGitter> <j8r> it isn't possible - methods overloads need to be known at compile time, and arrays are dynamic
<FromGitter> <j8r> you can use a tuple, and then eventually `#to_a`
<FromGitter> <j8r> or `{ point[0], point[1] }`
<FromGitter> <j8r> Besides it's not possible, not using arrays is safer, because this will introduce runtime errors regarding non existent/incorrect overloads
<FromGitter> <bararchy> Rank 82 in Crystal world wide haha http://git-awards.com/
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
<FromGitter> <greenbigfrog> Am I missing sth here? How tf could time_till_reset still be a Bool? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ `no overload matches 'sleep' with type (Bool | Time::Span)` [https://gitter.im/crystal-lang/crystal?at=5b5de00c3e264c71384b5c27]
<FromGitter> <diegogub> Guys, I have to check a TXT record on a domain DNS, is that possible with Crystal?
<FromGitter> <greenbigfrog> @diegogub This might help you: https://crystal-lang.org/api/0.25.1/Socket/Addrinfo.html
<FromGitter> <greenbigfrog> oh... wait... typeof is compile time type...
<FromGitter> <greenbigfrog> I want `#class`
<FromGitter> <greenbigfrog> it's still not working like I intend it to...
Groogy has quit [Read error: Connection reset by peer]
Groogy has joined #crystal-lang
Groogy has quit [Ping timeout: 248 seconds]
Groogy has joined #crystal-lang
akaiiro has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.2]
<FromGitter> <bararchy> @diegogub I don't think anyone implemented a full DNS shard other then basic resolve, but I'll take a look
<FromGitter> <diegogub> @bararchy @greenbigfrog thanks, I need it for domain validation
greengriminal has joined #crystal-lang
<Groogy> Is there a priority queue in Crystal?
<FromGitter> <greenbigfrog> for reference: I had to use `is_a?`
greengriminal has quit [Quit: This computer has gone to sleep]
Groogy has quit [Ping timeout: 268 seconds]
Groogy has joined #crystal-lang
alex`` has joined #crystal-lang
<oprypin> for reference: actual reference https://crystal-lang.org/docs/syntax_and_semantics/is_a.html
<FromGitter> <greenbigfrog> :P
akaiiro has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.2]
rohitpaulk has quit [Ping timeout: 244 seconds]
rbbi has joined #crystal-lang
Groogy has quit [Ping timeout: 245 seconds]
rbbi has quit [Client Quit]
Groogy has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
akaiiro has quit [Remote host closed the connection]
AndreasLutro has joined #crystal-lang
Groogy has quit [Ping timeout: 265 seconds]
Groogy has joined #crystal-lang
Groogy has quit [Ping timeout: 256 seconds]
<FromGitter> <sam0x17> is there a build flag that is automatically active when `crystal spec` is run? I want to detect that we are running specs from a macro
<FromGitter> <sam0x17> never mind -- using the --release flag actually makes more sense for my use case
hightower4 has joined #crystal-lang
<FromGitter> <sam0x17> (making a quick assertion lib that lets me do assertions C++ style throughout my program that aren't compiled in release mode )
<FromGitter> <Val> Build a tool like *gorun* for the fun ( https://github.com/erning/gorun ) but for Crystal, plus *shards* support with specific comment block : https://github.com/Val/crun
<crystal-gh> [crystal] straight-shoota opened pull request #6466: Fix Dir.glob to list broken symlinks (master...jm/fix/dir-glob-symlink-entry) https://git.io/fN23K
<FromGitter> <sam0x17> does anyone know how to remove the " marks around a StringLiteral in a macro? I need to do `puts "some string stuff {{macro_variable}}" ` where `macro_variable` could be a string literal or some other type without enclosing quotes. I have tried doing `{{macro_variable.gsub(/"/, "")}}` but the quotes remain, resulting in a compiler error.
<RX14> @sam0x17 `.id`
<FromGitter> <sam0x17> @RX14 thanks a bunch that worked!
greengriminal has joined #crystal-lang
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/fN2Gj
<crystal-gh> crystal/master bae4086 Johannes Müller: Fix Random#rand(Range(Float, Float)) to return Float (#6445)...
<FromGitter> <sam0x17> thanks again guys that all worked feel free to use the shard I made with your advice: https://github.com/sam0x17/assert.cr
<FromGitter> <j8r> @Val this already exists, you can `#!/usr/bin/crystal`
<FromGitter> <sam0x17> omg good to know
<FromGitter> <j8r> But this sucks because if you type special arguments like `--help`, it will print the crystal's help
<FromGitter> <j8r> for me having 2 way to run quickly a Crystal program is confusing, `crystal myprog` or `crystal run myprog`
<FromGitter> <asterite> @sam0x17 `unless something || true` is always true ;-)
<FromGitter> <sam0x17> yup
<FromGitter> <sam0x17> that's intentional
<FromGitter> <sam0x17> the return value was nil
<FromGitter> <sam0x17> that statement made it true
<FromGitter> <sam0x17> so if someone for some reason does assert!(blah) == true they get true
<FromGitter> <sam0x17> you'll never get false since that throws an exception
<FromGitter> <asterite> ooh... the `()` are around the whole `(raise unless ...)`
<FromGitter> <sam0x17> yup
<FromGitter> <asterite> a common idiom is to do `!!exp` for that
<FromGitter> <sam0x17> I was surprised that worked but it did so stuck with it
<FromGitter> <asterite> but it might not be clear
<FromGitter> <sam0x17> I originally had that actually, but then replaced that with my to_b construction
<FromGitter> <sam0x17> I guess that would work here though
<FromGitter> <asterite> I wonder why would someone need c++ assertions in crystal, though
<FromGitter> <asterite> 0 in c++ means null, that's why 0 is false in conditions
<FromGitter> <asterite> that's not the case in crystal
<FromGitter> <asterite> also "false", "no", and "nil" all look really strange... I wonder what's the use case
<FromGitter> <asterite> just curiosity :-)
<FromGitter> <sam0x17> I'm implementing AVL trees that maintain parent links, the false, no and nil stuff I should probably remove I ported this over from an old opinionated Object.to_b method I used to have in ruby
<FromGitter> <sam0x17> It's my attempt to be more intelligent about to_b but I can totally see why people would hate it
<FromGitter> <sam0x17> I'll remove it
<FromGitter> <sam0x17> @asterite regarding the !!expr thing, I would actually have to do `!(raise "assertion \"{{expr.id}}\" failed" unless Assert.to_b({{expr}}))` in this case since `!!(nil) => false` but we want `true` if no error occurred in the `raise` (which evaluates to `nil` if there is no error)
<FromGitter> <asterite> Ah, right
<FromGitter> <sam0x17> if this was a method body I would just do it on two lines to be more clear but AFAIK macros don't have an explicit return statement
<FromGitter> <sam0x17> do you think that makes it more clear or less clear doing the ! vs the || true @asterite
<FromGitter> <j8r> Trying to understand https://github.com/quinnj/Ryu.jl - but I'm too dumb 😄
<FromGitter> <sam0x17> it's all probably based on the original floating point RFC https://en.wikipedia.org/wiki/IEEE_754 https://ieeexplore.ieee.org/document/4610935/
<FromGitter> <sam0x17> (or the newer 2008 one (second link))
<FromGitter> <j8r> https://medium.com/@bellmar/is-cobol-holding-you-hostage-with-math-5498c0eb428b has helped me to understand a bit more
<FromGitter> <j8r> thanks for the links @sam0x17 :)
<travis-ci> crystal-lang/crystal#bae4086 (master - Fix Random#rand(Range(Float, Float)) to return Float (#6445)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/409630013
<FromGitter> <j8r> it seems you know well the subject :o
<FromGitter> <sam0x17> not at all
<FromGitter> <sam0x17> I just know of it ;)
<FromGitter> <sam0x17> (as in I don't know much about it)
<FromGitter> <sam0x17> I know enough about floating points to know I never trust them and prefer fixed precision or BigDecimal implementations when I can use them
<FromGitter> <sam0x17> unless I'm actually in a continuous environment like a video game
<FromGitter> <sam0x17> just don't use them to implement money
<FromGitter> <sam0x17> @j8r I actually read that COBOL article yesterday lol good stuff
<FromGitter> <j8r> It was in HackerNews :)
<FromGitter> <sam0x17> yup
greengriminal has quit [Quit: This computer has gone to sleep]
Ven`` has joined #crystal-lang
Ven`` has quit [Read error: No route to host]
bazaar has quit [Ping timeout: 260 seconds]
Ven`` has joined #crystal-lang
<FromGitter> <sam0x17> I extracted my to_b logic into its own shard since I tend to have this method floating around most of my private projects anyway https://github.com/sam0x17/to_b
<FromGitter> <sam0x17> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b5e499dd4527523f63d195d]
<FromGitter> <Timbus> hmmM
<FromGitter> <Timbus> I wrote something very similar, but i called it '.looks_true?'. Anyway, cool.
greengriminal has joined #crystal-lang
<FromGitter> <Val> @j8r with `crun` you can add shards in comments, see https://github.com/Val/crun#shards-support-example
<FromGitter> <sam0x17> @Timbus thanks
bazaar has joined #crystal-lang