RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.4 | Fund Crystal's 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
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<crystal-gh> [crystal] KCreate opened pull request #3929: Fixed wrong username (master...changelog-invalid-username) https://git.io/vMQij
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vMQPi
<crystal-gh> crystal/master 4d03a56 Leonard Schuetz: Fixed wrong username in changelog (#3929)
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
sz0 has joined #crystal-lang
triangles2 has quit [Quit: Leaving]
Kug3lis is now known as Kug3lis_off
<travis-ci> crystal-lang/crystal#4d03a56 (master - Fixed wrong username in changelog (#3929)): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/194132029
<FromGitter> <fridgerator> is there any built-in method to get the number of CPUs ?
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
triangles has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
ome has joined #crystal-lang
dhk has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
soveran has joined #crystal-lang
Ven has quit [Client Quit]
soveran has quit [Ping timeout: 245 seconds]
Ven has joined #crystal-lang
dhk has quit [Quit: Leaving]
Ven has quit [Read error: Connection reset by peer]
Ven_ has joined #crystal-lang
bjz has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
<tilpner> What would you need it for?
<tilpner> Oh, wait, that was hours ago
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ome has quit [Quit: Connection closed for inactivity]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
Ven has joined #crystal-lang
soveran has quit [Ping timeout: 245 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
go|dfish has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
unshadow has joined #crystal-lang
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
Kug3lis_off is now known as Kug3lis
etrepat has joined #crystal-lang
sz0 has joined #crystal-lang
DeBot has quit [Read error: Connection reset by peer]
DeBot has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
soveran has quit [Remote host closed the connection]
<crystal-gh> [crystal] blocknotes opened pull request #3931: Small improvements to example (master...patch-1) https://git.io/vMQpi
<DeBot> https://github.com/crystal-lang/crystal/pull/3931 (Small improvements to example)
sz0 has quit [Quit: Connection closed for inactivity]
Philpax has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.5 | Fund Crystal's 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
ome has joined #crystal-lang
fedruantine has quit [Ping timeout: 240 seconds]
fedruantine has joined #crystal-lang
Kug3lis has quit [Ping timeout: 240 seconds]
akwiatkowski has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 240 seconds]
<FromGitter> <zatherz> Is there something similiar like `object_id` in Crystal?
<FromGitter> <zatherz> basically, an ID that is always the same for the same object, but never equal between two objects
<FromGitter> <Sija> @zatherz there’s `Reference#object_id`, same as in Ruby
<FromGitter> <zatherz> Only reference?
<FromGitter> <Sija> only? ;)
<FromGitter> <Sija> Reference is an ancestor to almost every object
<FromGitter> <zatherz> ```undefined method 'object_id' for Int32 ⏎ ⏎ 3.object_id``` [https://gitter.im/crystal-lang/crystal?at=5884c741cbcb281770a05932]
<Papierkorb> That has no object id, doesn't make much sense, as it's not an object zatherz
<Papierkorb> Same goes for structs. They're `Value`s, and are not allocated on the heap
unshadow has quit [Quit: leaving]
<Papierkorb> zatherz, you can use #hash most of the time, but if you have two instances of a struct A, and both have the same values, they're equal by definition
<FromGitter> <zatherz> Is there any other way to reliably compare objects, even when `==` is overriden?
<Papierkorb> Value vs Reference in terms of comparison: https://carc.in/#/r/1ksr
<Papierkorb> zatherz, for References yes, for Values, by definition, no.
<Papierkorb> Are you sure you need that for Values though?
<FromGitter> <zatherz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5884c89cd43728124e8cc283]
<FromGitter> <zatherz> I do, because I want to submit a PR for Hash
<Papierkorb> zatherz, do you know the difference between struct and class, or Value and Reference for that matter?
<FromGitter> <zatherz> That changes behavior so that stuff like `x = {Float64::NAN => "abc"}; x.delete Float64::NAN` works
<Yxhuvud> That is loike, fundamentally misunderstanding how value types work
<Yxhuvud> -o
splitty_ has quit [Ping timeout: 240 seconds]
<FromGitter> <zatherz> No I get that if all the fields are equal, it's equal
<FromGitter> <zatherz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5884c925dcb66e4f7696db80]
<FromGitter> <zatherz> this is what I was supposed to send
<Papierkorb> That's not the point
<Yxhuvud> Isn't that just a side effect of Float::NaN being unequal to everything, including itself, as per spec?
<FromGitter> <zatherz> To give you a perspective, I want to submit a PR for the builtin Hash that will make it possible to do this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5884ca22074f7be76301f1f3]
<FromGitter> <zatherz> this is how it works in Ruby
<FromGitter> <zatherz> ```h = {Float64::NAN => nil} ⏎ h[Float64::NAN] = nil ⏎ h # => {nan.0 => nil, nan.0 => nil}``` ⏎ ⏎ this is something that happens currently [https://gitter.im/crystal-lang/crystal?at=5884ca63300f220a661c1f78]
<Yxhuvud> Yes, but the solution to this is not redefining hash for value types, it is redefining Hash so that it doesn't depend on ==.
<Yxhuvud> By the way, this is not limited to hashes. For example, Array#delete Float64::NAN would also fail to delete the element as it also use ==.
<Papierkorb> But if you use a Value as key, I expect that `hsh[Val.new] == hsh[Val.new]`
<Papierkorb> Anything else would be really weird
<Yxhuvud> papierkorb: Float::NAN != Float::NAN. And yeah, IEEE floating point numbers are really weird.
triangles has quit [Quit: Leaving]
<Papierkorb> Yxhuvud: Right, I just wanted to point out that replacing a corner-case with a even bigger corner-case isn't that great
<Yxhuvud> I wonder if anything can be done without resorting to hacks using is_a?(Float) though :/
<FromGitter> <zatherz> I wasn't going to redefine `hash`
<FromGitter> <zatherz> where did you get that from
<Yxhuvud> well, what alternative do you have?
<FromGitter> <zatherz> Ruby uses PTR_EQUAL which compares the pointers
<Papierkorb> That would break all Values
<FromGitter> <zatherz> of course
<Yxhuvud> Hmm, how do PTR_EQUAL work for immediate values? That is, values that are stored in the reference itself (ints, floats are examples of this). would that end up being a raw comparison of the bits in it?
<Yxhuvud> seems like it: {Float::NAN => 1, -Float::NAN => 2} => {NaN=>1, NaN=>2}
<Yxhuvud> {Float::NAN => 1, -Float::NAN => 2}.values_at(Float::NAN, -Float::NAN) => [1, nil]. Hm, wonder if I should put a ticket on that on the ruby tracker, because it is pretty weird.
<RX14> NaN is weird lol
<FromGitter> <zatherz> for reference https://github.com/crystal-lang/crystal/issues/3923
<FromGitter> <zatherz> also TIL that you can use `obj.@instancevar` to get values of instance variables
<FromGitter> <zatherz> ```class Test ⏎ @test = 42 ⏎ end ⏎ puts Test.new.@test # => 42``` [https://gitter.im/crystal-lang/crystal?at=5884d3d2074f7be76302222d]
<FromGitter> <zatherz> since when is `class_getter`, `class_property` and `class_setter` a thing?
<RX14> couple of releases
<FromGitter> <zatherz> Ooh it was added on the 8th of December
<FromGitter> <zatherz> in 0.20.3
ome has quit [Quit: Connection closed for inactivity]
<FromGitter> <zatherz> wow, `crystal tool expand` is in already
<FromGitter> <zatherz> I really should look at the changelogs more often
<RX14> finally a patch release without breaking changes
etrepat has quit [Quit: WeeChat 1.7]
<Papierkorb> ArchLinux community/crystal packet is on 0.20.3 still, and crystal-git from the AUR points at 0.20.4
<FromGitter> <zatherz> crystal-git pulls the latest git version
<FromGitter> <zatherz> it doesn't matter how it displays in the AUR
<FromGitter> <zatherz> I assume you're the one who marked it as out of date?
<FromGitter> <zatherz> actually wait
<FromGitter> <zatherz> what the hell
<FromGitter> <zatherz> who made that package
<Papierkorb> No I did not mark anything
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
splitty_ has joined #crystal-lang
soveran has quit [Ping timeout: 258 seconds]
Kug3lis has joined #crystal-lang
<FromGitter> <zatherz> Papierkorb: use this PKGBUILD https://hastebin.com/zeceriwaco.bash
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <firejox> How about define Float::NAN === Float::NAN is true? To use case equality for Values would also make sense.
<BlaXpirit> firejox, you know, for case equality it would make sense, but for comparison certainly not
<Papierkorb> Would actually be kinda interesting to be able to write hsh.delete(String)
<FromGitter> <MaxLap> That would mean that delete always iterate on every keys to work, instead of using hashes to jump to the value right away
<FromGitter> <firejox> @BlaXpirit Yeah, but for hash operation that's enough. There is no order required in hash.
unshadow has joined #crystal-lang
<FromGitter> <firejox> Well, if all NaN with same hash id and compare with case equality, there is no need to iterate every keys.
<unshadow> jhass: you here ?
<FromGitter> <MaxLap> I was referring to the hsh.delete(String) idea, which would need to iterate all keys each time. Making it quite a different operation that what is expected from delete.
<Yxhuvud> putting all strings in the same hash key may be the worst idea I've heard today.
<FromGitter> <MaxLap> Are there other operators for "equality" in Crystal than == and === ? Ruby has equal? (for identity) and eql? (for hashes, quite the unexplicit name).
<FromGitter> <MaxLap> And looking at the code right now... 1 and 1.0 will give you 2 different keys
unshadow has quit [Ping timeout: 255 seconds]
<FromGitter> <MaxLap> but should there be a hash collision putting those 2 values in the same bucket, you would get the first value of the bucket
<FromGitter> <MaxLap> At least it's how i understand it, because it uses == for the comparison of the keys, and doesn't check that the hashes are actually identical
unshadow has joined #crystal-lang
<FromGitter> <Sija> @MaxLap `Reference#same?`?
<FromGitter> <MaxLap> That's basically ruby's equal?, but only supporting references i guess.
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter> <MaxLap> holycrap floats are not.. lets say optimised for hashes lol
unshadow has quit [Ping timeout: 260 seconds]
unshadow has joined #crystal-lang
soveran has quit [Ping timeout: 245 seconds]
<FromGitter> <MaxLap> I'll open an issue with the problems i've just found. Here is a one liner that shows a few problems all at one: ⏎ `puts({0 => 1, 0.0 => 1000, 1.0 => 10, 1 => 100})`
<FromGitter> <MaxLap> This displays {0 => 1000, 1.0 => 10, 1 => 100}
unshadow has quit [Ping timeout: 240 seconds]
unshadow has joined #crystal-lang
Kug3lis has joined #crystal-lang
DeBot has quit [Remote host closed the connection]
DeBot has joined #crystal-lang
<Papierkorb> That's a Hash(Float64 | Int32, Int32)
<FromGitter> <MaxLap> Yes... but where is my 0.0 key&
<Papierkorb> Oh, overlooked the 0.0
<FromGitter> <MaxLap> It's gone because it ends up in the same bucket as my 0 key, and because hashes use ==, they are considered the same
<FromGitter> <MaxLap> It's basically the opposite of the problem mentionned a bit above about Float32::NAN not matching itself in the hash.
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<unshadow> I have this Makefile: https://github.com/bararchy/sslscanner/blob/master/Makefile and I want to tell Crystal to build against the OpenSSL static librery instead of the global one, how do I do that ?
soveran has quit [Remote host closed the connection]
bjz_ has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter> <MaxLap> There was already an issue about the Float32::NAN, so i just added my case to it.
<FromGitter> <MaxLap> I also found https://github.com/crystal-lang/crystal/issues/3932 while looking into the NAN thing..
<unshadow> So... anyone got an idea on next steps to try: https://github.com/crystal-lang/crystal/issues/3933 ?
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…]
bjz has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
bjz_ has joined #crystal-lang
bjz_ has quit [Read error: Connection reset by peer]
<FromGitter> <bash> Is this bad or just pure evil? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5885235411e7a7f61dcebbc8]
<Yxhuvud> Do you have to choose?
Philpax has joined #crystal-lang
<FromGitter> <bash> Nah, you can have both
<FromGitter> <bash> So serious question: If I want to have a cancellable timer... Is there no better solution than having to wait for the sleep to complete and then check if the timer has been cancelled? (Something like this: https://github.com/andrewhamon/quartz/blob/master/src/quartz/timer.cr#L11)
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Philpax has quit [Ping timeout: 240 seconds]
<BlaXpirit> bash, well that's a pretty good approach, why complicate things
<FromGitter> <bash> Fair enough
<BlaXpirit> bash, you could have a fiber that waits on a channel. and the channel may receive either a "do it" or "don't do it" message
<BlaXpirit> but that's an additional fiber just for waiting
<FromGitter> <bash> ... and I don't want to send a "do it" message
<FromGitter> <bash> oh
<FromGitter> <bash> this looks interesting
<BlaXpirit> bash, well, that would be a fiber that sleeps and then sends a "do it" message
<BlaXpirit> and heh i was gonna name a project "quartz" because it has letters 'q' and 't' but whatever, that project isn't happening any time soon
<BlaXpirit> bash, i think that 'timeout' thing should be (and maybe is planned to be) in standard library. but it's a very small utility to use a powerful built in feature - "select". i think you could come up with something smart with that and timers
<BlaXpirit> i'm off
soveran has quit [Remote host closed the connection]
Philpax has joined #crystal-lang
Kug3lis has joined #crystal-lang
<FromGitter> <MaxLap> Is there and equivalent to ruby's Module#prepend?
Papierkorb has quit [Ping timeout: 258 seconds]
Papierkorb has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akwiatkowski has quit [Ping timeout: 256 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 260 seconds]