ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.19.4 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
hako_ has quit [Ping timeout: 250 seconds]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<FromGitter> <cjgajard> I want to know what you think about this because I can't find enough arguments to have a strong opinion about it by myself. Is `for` macro an "anti-pattern" for similar methods definition? (check this example: https://gist.github.com/cjgajard/dff3b9dae6aa4874e1b7b6ca4e4b2c83)
hako has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
kulelu88 has joined #crystal-lang
<FromGitter> <jwoertink> @cjgajard If you only have those 3 properties, you could do `getter x, y, z`. It would only be one line instead of the 3 with the `for` loop
<FromGitter> <jwoertink> I think the for macro works nicely for the other ones though because there's so many interpolations
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
soveran has quit [Remote host closed the connection]
Philpax has joined #crystal-lang
<FromGitter> <phoffer> How do I create a hash with a default value of an empty array? i.e. ⏎ ⏎ ```FEEDS = Hash(String, Array(String)).new ⏎ FEEDS[“crystal”] << “string”``` ⏎ ⏎ doing that errors with `missing hash key` [https://gitter.im/crystal-lang/crystal?at=581d5a12aa8f8c4b328f0763]
<FromGitter> <jwoertink> ```FEEDS["crystal"] = ["string"] ⏎ FEEDS["crystal"] << "other"``` [https://gitter.im/crystal-lang/crystal?at=581d5a9be097df7575715fc9]
<FromGitter> <jwoertink> you could try that @phoffer
<FromGitter> <jwoertink> Your other option could be
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=581d5b45e462097a300e2e54]
<FromGitter> <jwoertink> initialize the has where each value will automatically be an array of strings
<FromGitter> <phoffer> Oh that’s the missing piece there. I think I’m going to explicitly initialize the arrays, I’m just a little annoyed I couldn’t get the first thing working
<FromGitter> <phoffer> btw, that second one does suffer the same issue that Ruby has with a default value of an array for a hash
<FromGitter> <jwoertink> yeah
<FromGitter> <luislavena> @phoffer you can use the block form of `Hash.new`
<FromGitter> <luislavena> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=581d5c33e097df7575716629]
<FromGitter> <phoffer> I knew I should have tried that @luislavena. It seems like every time I get stuck, I don’t try the Ruby way, and usually it’s an instance where they are the same :smile:
<FromGitter> <phoffer> thanks gentlemen!
<FromGitter> <jwoertink> :thumbsup:
kulelu88 has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 256 seconds]
lacour has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
pawnbox_ has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
matp_ has joined #crystal-lang
matp has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
hako has quit [Ping timeout: 250 seconds]
_whitelogger has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<crystal-gh> [crystal] Papierkorb opened pull request #3503: Add Int#to_big_i (master...master) https://git.io/vX8KD
<FromGitter> <zatherz> is there any macros like `getter`, `setter` and `property` for class variables?
<BlaXpirit> zatherz, no
<FromGitter> <zatherz> should I contribute it?
<BlaXpirit> zatherz, it's about the design, not about writing the 10 easy lines of code
<FromGitter> <zatherz> which is exactly why I asked if I should contribute it
<FromGitter> <zatherz> reading comprehension
<BlaXpirit> this has been brought up before. there was no design that everyone was happy with, so this got indefinitely postponed. it's not certain where this should even be present at all
<BlaXpirit> hm jhass has been bringing up class_property since almost 2 years ago
<FromGitter> <zatherz> `self.property` mentioned a year ago here https://github.com/crystal-lang/crystal/issues/444
<BlaXpirit> well yeah but that's not gonna work
<FromGitter> <zatherz> yes, just searching variations
<FromGitter> <zatherz> `class_property` was never submitted in a PR
<BlaXpirit> usually controversial changes are discussed in issues, so the pull request itself can be all about the implementation details
<BlaXpirit> well maybe just go for it
<BlaXpirit> it's difficult to avoid code duplication in those macros
<crystal-gh> [crystal] dylandy opened pull request #3504: added factorial function to int and float (master...factorial) https://git.io/vX86H
bjz has quit [Ping timeout: 265 seconds]
bjz has joined #crystal-lang
<crystal-gh> [crystal] Papierkorb closed pull request #3503: Add Int#to_big_i (master...master) https://git.io/vX8KD
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Papierkorb> > instance variable '@buckets' of Torrent::PiecePicker::RarestFirst must be Array(Array(UInt32)), not Array(Array(UInt32))
<Papierkorb> Now this will be fun to figure out
<Papierkorb> And now I made the compiler crash by it dereferencing a NULL pointer
<FromGitter> <jwoertink> lol
<Papierkorb> https://github.com/Papierkorb/torrent/tree/compiler-crash - Can someone check it out, (crystal deps, crystal spec) and see if it does for them?
<Papierkorb> Crystal is on master HEAD
<Papierkorb> A second gem, if you outcomment https://github.com/Papierkorb/torrent/blob/compiler-crash/spec/torrent/transfer_spec.cr#L63 the compiler complains: that instance variable '@buckets' of Torrent::PiecePicker::RarestFirst must be Array(Array(UInt32)), not Array(Array(UInt32))
<Papierkorb> The same code works fine outside spec2, so somehow spec2 is basically benchmarking the compiler heh
<Papierkorb> For a quick look, I pasted both outputs here: https://gist.github.com/Papierkorb/d083adb0893c4f59b247f425cba2f75b
<Papierkorb> No idea yet how I could minimize either cases to something shorter
Philpax has quit [Ping timeout: 260 seconds]
<BlaXpirit> Papierkorb, because of all these corner cases that spec2 causes i consider it not worth using
<BlaXpirit> and the atrocious traceback outputs, of course
<Papierkorb> BlaXpirit: Well, a compiler crash is always a compiler bug
<Papierkorb> Also, to me, `spec` is just not that good. let and subject alone make tests so easier to write.
<BlaXpirit> spec is very bad
<BlaXpirit> then again, can't expect too much from a compiled language
kulelu88 has joined #crystal-lang
<Papierkorb> Why not? spec2 shows what's possible, aside from the awful error traces (though I don't know how to improve them), it does most of what I come to love of RSpec
<BlaXpirit> spec2 is only a slight improvement, but with the mentioned significant disadvantages
<Papierkorb> To me it's not. And regardless of opinion, a compiler crash is always a bug
<Papierkorb> Ah. Looks like an issue with the `mock` shard
<BlaXpirit> Papierkorb, wait, where does that one come in?
<BlaXpirit> i dont see it referenced in your torrent code
<Papierkorb> shard.yml, spec_helper.cr, but not used anywhere, only commented code in the transfer_spec.cr
<Papierkorb> Ah it's not commented in the version online. Well, I commented it out and the issue was the same
<Papierkorb> I removed the require for it too and I suddenly was able to run specs again. Not what I expected (it ran fine with the require before), but ... hey I can continue for now.
<BlaXpirit> Papierkorb, i still don't see anything in shard.yml, have you possibly forgotten to update it?
<Papierkorb> spec2-mocks pulls in the mocks shard
<BlaXpirit> sorry :( was looking at master
<BlaXpirit> anyhow, yes, your tests and their usage of spec2 look very nice
<Papierkorb> Thanks :3
<Papierkorb> Aaand now I'm getting "instance variable '@buckets' of Torrent::PiecePicker::RarestFirst must be Array(Array(UInt32)), not Array(Array(UInt32))" again. Fascinating.
<Papierkorb> If I even knew how to begin debugging that issue
<BlaXpirit> now without mock?
<Papierkorb> Outside of spec2 RarestFirst runs fine as expected
<Papierkorb> Yes
<Papierkorb> You just need to remove the require for spec2-mocks, the Mocks.create.. lines and then comment in https://github.com/Papierkorb/torrent/blob/compiler-crash/spec/torrent/transfer_spec.cr#L63
<Papierkorb> Fails for me with the latest crystal from the release and on master, same error
<maxpowa> Is it possible to define a method_missing statically? I could be doing something wrong in this class but it doesn't appear to be working...
<BlaXpirit> maxpowa, I think there is no way at all to have a method_missing for class methods
<maxpowa> hmm ok
<maxpowa> thanks
<Papierkorb> maxpowa: Although more tedious, you could iterate over a list of method to forward and then create the forwarders in the macro
<Papierkorb> {% for name in [ :foo, :bar ] %}def self.{{ name.id }}(*args, **kwargs); INSTANCE.@forgot.{{ name.id }}(*args, **kwargs); end {% end %}
<Papierkorb> Something like that maxpowa
<maxpowa> yeah i guess that's possible but not really sure it's that important, the alternative is just Bot.instance.<method>
<BlaXpirit> maxpowa, the best alternative is to not use a singleton
<maxpowa> Singletons make reference from modules though
<maxpowa> makes reference easy*
<Papierkorb> maxpowa: It depends. Avoid singletons if possible, instead pass an instance of the class around
<Papierkorb> maxpowa: More often than not a "property foo : Bar" already makes that less tedious
lacour has joined #crystal-lang
<crystal-gh> [crystal] joshrickard opened pull request #3505: fix readme link to contribution guide (master...fix-contributing-link) https://git.io/vX8QX
jeromegn_ has quit [Ping timeout: 260 seconds]
jeromegn_ has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
kulelu88 has quit [Ping timeout: 252 seconds]
<Papierkorb> Does someone have a rough estimate of when to expect the next release?
<FromGitter> <sdogruyol> i expect 0.20.0 to be released next week
<Papierkorb> Great, then I won't bother with the error `Random::DEFAULT.next_u` not being defined.
<Papierkorb> Why was it renamed btw? isn't #next_u32 clearer?
<FromGitter> <sdogruyol> i dont know what that is
<Papierkorb> The first is the URL given in the docs, so that's what's in the current release, and the latter is master
<Papierkorb> For a moment I thought I was going insane
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> i have no idea how or why, but adding debug symbols to a binary breaks UNIXSocket
<RX14> it makes no sense
<RX14> it's absolutely consistent every time, builds with debug symbols generate an impossible errno, and without works fine
<FromGitter> <sdogruyol> what kind of symbols?
<FromGitter> <sdogruyol> debug*
<RX14> just adding -d
<RX14> ass you can see from the gist
bjz has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Read error: Connection reset by peer]
Raimondii is now known as Raimondi
<FromGitter> <sdogruyol> there was an issue in Crystal about debug flag breaking builds
<FromGitter> <sdogruyol> guess it's related to that
pawnbox has quit [Remote host closed the connection]
vikaton has joined #crystal-lang
A124 has quit [Quit: '']
<BlaXpirit> Papierkorb, regarding `next_u`, you could click "blame" and check out the line you linked. you'd find #3402
<DeBot> https://github.com/crystal-lang/crystal/pull/3402 (Rework the Random module)
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] ysbaddaden closed pull request #3505: fix readme link to contribution guide (master...fix-contributing-link) https://git.io/vX8QX