<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> 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
<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
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 )
<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!
<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> 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