jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<crystal-gh> [crystal] jhass opened pull request #1459: HTTP::Headers: Preserve input case, indifferent access between - and _ (master...headers_compare) http://git.io/vZKJ5
<jokke> hm
<jokke> i tried to reproduce it
<jokke> but can't get any relevant results
<jokke> of course it's unlikely that it cascades down to the last else
<jhass> what's your LLVM version?
<jokke> 3.6.2
<jhass> k, same
<crystal-gh> [crystal] jreinert closed pull request #1416: normalize dash/underscore separated http header names correctly (master...master) http://git.io/vZmNr
<jokke> oh
<jokke> seems that the pr breaks some specs
<jokke> ah but those are fixed easily
kyrylo has quit [Ping timeout: 264 seconds]
MikeC has joined #crystal-lang
<jokke> yup that should do it
<MikeC> Howdy all
<jokke> hi MikeC
knoopx has quit [Remote host closed the connection]
<MikeC> Been playing with Crystal some and really like it (I'm a Rubiest). Am considering trying it out on some small web services. All the parts seem to be there (web frameworks, postgres driver) anyone doing this currently?
<jhass> >> "I'm all crystal on the backend ;)"
<DeBot> jhass: # => "I'm all crystal on the backend ;)" - http://carc.in/#/r/f0l
<MikeC> oh nice...
<jhass> jokke: if .. elseif .. else 32.39M (± 4.05%) fastest
<jhass> guard clause 32.09M (± 4.66%) 1.01× slower
<jhass> if I use RAND.next_bool || RAND.next_bool || RAND.next_bool
<jhass> for the conditions
<jokke> mmh
<jhass> oh, actually I had the 300k difference before, didn't notice :/
<MikeC> Thanks jhass, anything obvious to watch out for?
<jhass> MikeC: not really, code's on jhass/carc.in
<MikeC> ok.. many thanks!
<jhass> jokke: yep, quite consistently ~200-500k faster for me. Do you have a good entropy source (like haveged)?
<jokke> nope
<jhass> might explain the bigger inconsistencies when using randomness then
<jokke> now i do
<jhass> let's also try with cpu pinning
<jokke> if .. elseif .. else 39.6M (± 1.20%) fastest
<jokke> guard clause 39.55M (± 1.15%) 1.00× slower
<jokke> that's minimal
<jokke> ok now even 1.02x slower
<jokke> now if elseif was 1.01 slower
<jhass> interesting, I get less consistent results with cpu pinning ...
<jhass> I guess I leave it for now
<jhass> just hit a hard to optimize case I guess
Neverdie has joined #crystal-lang
<jhass> shit, Ary's right, the comparator is really slow
<jhass> just tried wrapping the key into a struct instead
<jhass> already looking good
<jhass> Fetch Content-Type from HTTP::Headers { "Content-Type" => "bar" }
<jhass> HeadersMaster 2.36M (±25.62%) 8.11× slower
<jhass> HeadersPR 17.9M (± 4.50%) 1.07× slower
<jhass> HeadersCompare 19.12M (± 3.13%) fastest
MikeC has quit [Quit: Page closed]
jeromegn_ has joined #crystal-lang
jeromegn has quit [Ping timeout: 250 seconds]
jeromegn_ is now known as jeromegn
trapped has joined #crystal-lang
<dzv> how do i make a common initialize method when there are other initialize methods with different arguments? http://carc.in/#/r/f0n
<jeromegn> dzv: you'd need to call it with new and no arguments
<jeromegn> try new() instead of super()
<jeromegn> actually... not sure if that'll work
<dzv> it doesn't create an extra object?
<dzv> oh
<dzv> weird
<dzv> didn't work. http://carc.in/#/r/f0w
buggs has quit [Quit: WeeChat 0.4.2]
sardaukar has quit [Ping timeout: 256 seconds]
wonderbread_ has joined #crystal-lang
wonderbreadz has quit [Ping timeout: 250 seconds]
wonderbread_ is now known as wonderbreadz
trapped has quit [Read error: Connection reset by peer]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vZKCD
<crystal-gh> crystal/master 75cd6ce Ary Borenszweig: Use T* instead of Pointer(T) in to_s for nodes inside libs
ponga has quit [Quit: Connection closed for inactivity]
leafybasil has joined #crystal-lang
<travis-ci> manastech/crystal#75cd6ce (master - Use T* instead of Pointer(T) in to_s for nodes inside libs): The build passed. https://travis-ci.org/manastech/crystal/builds/80055213
<asterite> dzv: call initialize: http://carc.in/#/r/f0x
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 264 seconds]
sardaukar has joined #crystal-lang
kulelu88 has left #crystal-lang ["Leaving"]
MikeC has joined #crystal-lang
MikeC has quit [Client Quit]
<jeromegn> is there a way to create just a generic IO instance?
<jeromegn> I know it's a module...
<jeromegn> I'm trying to fake some IO stuff for specs
<jeromegn> going to look at the crystal specs...
<wmoxam> How do you specify a callback that takes multiple arguments in a C binding?
jeromegn has quit [Quit: jeromegn]
Neverdie has quit [Quit: http://radiux.io/]
BlaXpirit has joined #crystal-lang
<jsaak> if true then 1 else 2 end
<jsaak> this does not work in crystal is it intentional?
<BlaXpirit> jsaak, `then` isn't a thing...
<BlaXpirit> u can replace it with `;` but best avoid this
buggs has joined #crystal-lang
<jhass> wmoxam: cb : (A, B -> R)
kyrylo has joined #crystal-lang
<jsaak> ok, there is also Hash not implementing Enumerable
<BlaXpirit> makes total sense
<jsaak> why?
<jhass> jsaak: because we have autosplat and no tuple decomposition in block args (yet)
<jhass> *no autosplat
<jsaak> ahh ok
<jhass> so each; yield a; end; != each; yield a, b; end;, Enumerable requires the former, Hash provides the latter
<jsaak> so you planning to add this functionality?
<jhass> tuple decomposition is somewhat likely to happen, autosplat is still undecided I think
<jsaak> (i just want to help you mentioning the errors i encountered, maybe i found something new)
<jhass> sure, yw
<jsaak> i did not found also any decimal data type, where 0.1+0.1+0.1 == 0.3 are there any?
<jsaak> or shall i write my own?
<jhass> we already use gmp for BigInt, should be fairly easy to do a first cheap BigDecimal with it too
<jsaak> ok thanks
<jhass> so that'd be a welcome contribution to stdlib I'd say ;)
<jsaak> fork crystal , make BigDecimal branch, create pull request?
<jhass> pretty much
willl has quit [Quit: Connection closed for inactivity]
<jsaak> ohh thanks
<jhass> I'd also love to see Rational
<jhass> probably the most underused datatype in Ruby
<jsaak> it is very slow in ruby, that is why i avoided that
<jsaak> or was in 1.8 times, not sure about 2.x
<jhass> 2.2 or 2.1 added a literal, maybe the improved it by now
<jhass> gmp has functions for it too I think, would be interesting how they compare at least
sardaukar has quit [Ping timeout: 256 seconds]
sardaukar has joined #crystal-lang
<jsaak> i also found that type reduction does not work for global variables
<jsaak> gives compile time error
apt-get has joined #crystal-lang
apt-get has quit [Ping timeout: 250 seconds]
nakilon has joined #crystal-lang
kyrylo has quit [Quit: Konversation terminated!]
kyrylo has joined #crystal-lang
<jhass> jsaak: they're global, so another thread might change them between you checking the value and then doing something on that assumption
<jhass> besides, don't use globals :P
<jhass> but the proper way to do that is to assign them to a local first
<jhass> ?non_local_if=See https://github.com/manastech/crystal/issues/477 for some background on why resolving unions only works for local variables.
<DeBot> jhass: Set non_local_if.
apt-get has joined #crystal-lang
<jsaak> yeah global was a temporary hack to make this damned program compile, but still no luck :)
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 256 seconds]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
apt-get has quit [Read error: No route to host]
leafybasil has joined #crystal-lang
<nakilon> jhass, about catch/throw usage -- I'm about to minify an example from Ruby the code I'm currently working on
elia has joined #crystal-lang
<nakilon> the `some_list_of_lists` actually could have a lot of levels deep
<nakilon> *could be
<nakilon> yeah I could use `return` here, but it won't work if I need some things be done right after catch block but inside the lambda
elia has quit [Quit: Computer has gone to sleep.]
<crystal-gh> [crystal] jhass opened pull request #1461: Suggest to start with 0.1.0 in library template (master...template_version) http://git.io/vZ69M
<jhass> nakilon: this is hard to argue on fake code, but if it gets that complex it probably warrants a class
<nakilon> hm, while it's not possible to run Ruby code using Crystal compiler, it should be trivial to run Crystal code using Ruby interpreter
<jhass> a mruby binding should actually be feasible :P
<nakilon> classes are for OOP, instantiating, inheritance -- here I just want to break through more than one loop stack, that is trivial and what the catch/throw are implemented in Ruby for
<jhass> funny that I never had a use for it in all the Ruby code I wrote then
<jhass> and I disagree, classes are for packing up related data and/or logic
<nakilon> you mean cleaning the namespace using modules
<nakilon> encapsulation
<nakilon> the one should use module instead of class in Ruby if he doesn't need instantiating
<nakilon> it's my point of view
havenwood has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
kyrylo has left #crystal-lang ["Konversation terminated!"]
<jhass> well sure, but that's not what I mean
leafybasil has quit [Ping timeout: 265 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 260 seconds]
leafybasil has joined #crystal-lang
<crystal-gh> [crystal] jhass pushed 2 new commits to master: http://git.io/vZivE
<crystal-gh> crystal/master 8a84e68 Jonne Haß: Suggest to start with 0.1.0 in library template...
<crystal-gh> crystal/master f801fd3 Jonne Haß: Merge pull request #1461 from jhass/template_version...
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vZift
<crystal-gh> crystal/master 500c772 Ary Borenszweig: Fixed TypeDef#to_s
<travis-ci> manastech/crystal#f801fd3 (master - Merge pull request #1461 from jhass/template_version): The build passed. https://travis-ci.org/manastech/crystal/builds/80093774
<travis-ci> manastech/crystal#500c772 (master - Fixed TypeDef#to_s): The build was broken. https://travis-ci.org/manastech/crystal/builds/80094042
jeromegn has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vZiIT
<crystal-gh> crystal/master 7bfe196 Ary Borenszweig: Fixed spec
<travis-ci> manastech/crystal#7bfe196 (master - Fixed spec): The build was fixed. https://travis-ci.org/manastech/crystal/builds/80095934
<jeromegn> How would I get the bytes representation of a Float64?
<jeromegn> or I guess, most types?
<jeromegn> for a string I used to_slice
<jhass> thing is there's no "the bytes representation"
<jeromegn> well
<jeromegn> I guess 8 bytes of the memory starting at pointer x?
<jeromegn> apparently pointerof(self) doesn't work
<jeromegn> have to assign it before I guess so that it's in memory
Ven has joined #crystal-lang
<jhass> >> f = Float32::MAX; Slice.new(pointerof(f) as UInt8*, sizeof(typeof(f))
<DeBot> jhass: Syntax error in eval:6: expecting token ')', not 'end' - http://carc.in/#/r/f1w
<jhass> >> f = Float32::MAX; Slice.new(pointerof(f) as UInt8*, sizeof(typeof(f)))
<DeBot> jhass: # => [0, 0, 128, 127] - http://carc.in/#/r/f1x
<jeromegn> :)
<jhass> idk if that makes any sense
<jeromegn> I was probably not using the right language
<jeromegn> *nomenclature
<jhass> I mean IEEE754 doesn't partition into bytes
<jeromegn> I see
<jeromegn> yea, I'm implementing the cryptic BSON spec
<jhass> >> f = Float64::MAX; Slice.new(pointerof(f) as UInt8*, sizeof(typeof(f)))
<DeBot> jhass: # => [0, 0, 0, 0, 0, 0, 240, 127] - http://carc.in/#/r/f1y
<jhass> well, guess it's somewhat consistent
<jeromegn> >> n = 20.to_i32; Slice.new(pointerof(n) as UInt8*, sizeof(typeof(n)))
<DeBot> jeromegn: # => [20, 0, 0, 0] - http://carc.in/#/r/f20
<jeromegn> >> n = 20.to_i32; s = Slice.new(pointerof(n) as UInt8*, sizeof(typeof(n))); b1,b2,b3,b4 = s; t32 = {b1, b2, b3, b4}; (pointerof(t32) as Int32*).value
<DeBot> jeromegn: # => 20 - http://carc.in/#/r/f22
<jeromegn> looks alright
<jhass> >> f = Float64::MAX; s = Slice.new(pointerof(f) as UInt8*, sizeof(typeof(f))); (s.pointer as Float64*).value
<DeBot> jhass: Error in line 4: wrong number of arguments for 'Slice(UInt8)#pointer' (0 for 1) - http://carc.in/#/r/f26
<jhass> >> f = Float64::MAX; s = Slice.new(pointerof(f) as UInt8*, sizeof(typeof(f))); (s[0] as Float64*).value
<DeBot> jhass: Error in line 4: can't cast UInt8 to Pointer(Float64) - http://carc.in/#/r/f28
<jhass> meh
<jhass> >> f = Float64::MAX; s = Slice.new(pointerof(f) as UInt8*, sizeof(typeof(f))); (s.pointer(0) as Float64*).value
<DeBot> jhass: # => inf - http://carc.in/#/r/f29
<jhass> wait what
<jhass> >> Float64::MAX
<DeBot> jhass: # => inf - http://carc.in/#/r/f2a
<jhass> not sure that's a good idea
<jeromegn> yea me neither... at least for Floats, it seems off
<jeromegn> I<m trying to serialize stuff back to BSON
trapped has joined #crystal-lang
<jeromegn> so I'm passing around a IO instance and writing bytes ot it
<jeromegn> *to it
kleech has joined #crystal-lang
<kleech> any ideas why require "net/http" does not work (can't find file)?
<jeromegn> jhass: ok it's def not reliable...
<jhass> kleech: it's http/client
<jhass> heh, it's a year old :P
<jeromegn> >> n = 6; r, w = IO.pipe; w.write Slice(UInt8).new(pointerof(n) as UInt8*, sizeof(typeof(n))); bytes = Slice(UInt8).new(sizeof(typeof(n))); r.read(bytes); bytes
<DeBot> jeromegn: # => [6, 0, 0, 0] - http://carc.in/#/r/f2t
<jeromegn> hmm
<jeromegn> I guess it does work... weird, I'm getting different results locally. must be something else
<jhass> off by one? :P
Ven has quit [Read error: No route to host]
kleech has quit [Remote host closed the connection]
<jeromegn> off by two
<jeromegn> :(
<jeromegn> off by one was yesterday! jeeezzz
<jeromegn> :)
<jhass> gotta scale up somehow
<jeromegn> yes
<jeromegn> I'm storing [6, 0, 0, 0] but when reading the IO I get [4, 0, 0, 0]
<jhass> mmh
<jhass> signed vs unsigned?
<BlaXpirit> jhass, that's not how it works :p
<jhass> mmh, no it's the second bit that's lost
<jeromegn> >> 6.to_u32
<jhass> who knows!
<DeBot> jeromegn: # => 6 - http://carc.in/#/r/f2w
<jhass> >> 6u32
<DeBot> jhass: # => 6 - http://carc.in/#/r/f2x
<BlaXpirit> >> n = -6; (pointerof(n) as Pointer(UInt32)).value
<DeBot> BlaXpirit: # => 4294967290 - http://carc.in/#/r/f2y
<BlaXpirit> thats more like it
<jeromegn> writing slices vs writing Arrays of UInt8 seems to yield different effects
<jeromegn> although very ugly
<jeromegn> but now that i'm writing slices, things are off...
<jeromegn> unless..
<jeromegn> I did switch from a StringIO to a normal IO thingy...
<jeromegn> >> r, w = IO.pipe; "#{r.class} #{w.class}"
<DeBot> jeromegn: # => "FileDescriptorIO FileDescriptorIO" - http://carc.in/#/r/f2z
<jeromegn> hmm
<BlaXpirit> >> UInt8[2,5,3,2]
<jeromegn> interesting
<DeBot> BlaXpirit: # => [2, 5, 3, 2] - http://carc.in/#/r/f30
<BlaXpirit> first time i see this
<jeromegn> I saw that in the message_pack lib I think
<jeromegn> nah same effect with StringIO
<BlaXpirit> jeromegn, isolate it and see what happens then
<BlaXpirit> i dont think array can be different from slice, if everything is done correctly
<jeromegn> I'm trying a few things, will report back! :)
<jeromegn> might have found a bug...
<jeromegn> 0.7.7/src/io/file_descriptor_io.cr:245: undefined constant SEEK_SET
<jeromegn> seek(0, SEEK_SET)
<jeromegn> trying to rewind a FileDescriptorIO
<jeromegn> so even if I write 100, it still ends up as 4
apt-get has joined #crystal-lang
<jeromegn> but all the other writes are good
<jeromegn> I was not expecting that: http://play.crystal-lang.org/#/r/f33
<jeromegn> also, those values change every time i run them
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vZiEK
<crystal-gh> crystal/master fbf2eeb Ary Borenszweig: Use "T[N]" instead of "StaticArray(T, N)" when doing to_s inside lib def
<BlaXpirit> jeromegn, well duh. u have a pointer to unallocated memory
<BlaXpirit> just what i expected
<jeromegn> how do I fix that?
Neverdie has joined #crystal-lang
<BlaXpirit> jeromegn, this code structure isn't helping.. i dont know how to adapt this to it
<jeromegn> the code structure is off?
<BlaXpirit> basically you're copying `self` into `n`, then getting a pointer to `n`, then deleting `n`, so it points to whatever
<jeromegn> right
<BlaXpirit> just don't make the copy. don't use an object's own method to return a pointer
<jeromegn> I can try that
<jeromegn> I inspired from String#to_slice which uses it cstr
<jeromegn> *its cstr
<jeromegn> I couldn't find an equivalent for Int so I tried using self, but you can't get a pointerof(self)
<BlaXpirit> right
<BlaXpirit> also remember my warnings? is bson really endinanness-dependent?
<travis-ci> manastech/crystal#fbf2eeb (master - Use "T[N]" instead of "StaticArray(T, N)" when doing to_s inside lib def): The build passed. https://travis-ci.org/manastech/crystal/builds/80103851
<jeromegn> I remember :) I mean, I'm not 100% sure, but I saw that mentioned in different places
<jeromegn> this is how the ruby implementation does it:
<BlaXpirit> jeromegn, well they use pack, to which they specify byte order
<jeromegn> yea and they specify little-endian, right?
<jeromegn> s< l< q< | | little endian
<jeromegn> so I guess I can trust that, since MongoDB, Inc. wrote that thing
<BlaXpirit> jeromegn, yes, so they specify it, but when you fiddle with pointers you can't specify it, because you use whatever your computer uses
<jeromegn> oh, right
<BlaXpirit> then again, there are barely any big-endian computers (crystal probably doesnt support any)
<jeromegn> but given I wanted to be sure, how would I do it?
<jeromegn> manually rewrite the bytes order
<BlaXpirit> >> n = 123456; [n>>24, n>>16, n>>8, n].map &.to_u8
<DeBot> BlaXpirit: # => [0, 1, 226, 64] - http://carc.in/#/r/f38
<jeromegn> oh yes you did mention that yesterday
<jeromegn> my bad
<BlaXpirit> a = UInt8[0, 1, 226, 64]; (a[0].to_i<<24)&(a[1].to_i<<16)&(a[2].to_i<<8)&(a[3].to_i)
<BlaXpirit> >> a = UInt8[0, 1, 226, 64]; (a[0].to_i<<24)&(a[1].to_i<<16)&(a[2].to_i<<8)&(a[3].to_i)
<DeBot> BlaXpirit: # => 0 - http://carc.in/#/r/f39
<BlaXpirit> ok then :|
<BlaXpirit> >> a = UInt8[0, 1, 226, 64]; (a[0].to_i<<24) | (a[1].to_i<<16) | (a[2].to_i<<8) | (a[3].to_i)
<DeBot> BlaXpirit: # => 123456 - http://carc.in/#/r/f3a
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ponga has joined #crystal-lang
<jeromegn> huh
<jeromegn> crystal spec ✱ ◼
<jeromegn> ....Could not raise
<jhass> sounds like you messed up the stack :P
<jeromegn> I never do that
<jeromegn> :)
<jeromegn> that happens when I use the "should"
<jeromegn> in my spec
<jeromegn> BlaXpirit: How would I initially know what numbers to put in the UInt8[] bracket?
<jeromegn> oh nvm
<jeromegn> sorry, my bad agan
<asterite> jeromegn: if that's on mac, try using the HEAD compiler, we "fixed" a bug related to that
<asterite> (the "Could not raise")
<jeromegn> ah
<jeromegn> yep, ok cool. for some reason it works fine now
<jhass> asterite: do you know what PartialComparable is about?
<jeromegn> how would I shift the bits for a Int64?
<jeromegn> for little-endianness
Ven has joined #crystal-lang
<jeromegn> oh I think I got it
<jeromegn> oh wait, I can't bit shift a float?
<BlaXpirit> jeromegn, oh :|
<BlaXpirit> for int64 that would be 56, 48, etc
<jeromegn> yea
<jeromegn> I think that'll work
<jeromegn> but not sure what to do about floats
<BlaXpirit> for a float i dont know...... i wonder if casting it to int64 then doing this would be any better than casting it to slice[uint8]
<BlaXpirit> i'll see what they do here, but later https://github.com/python/cpython/blob/master/Modules/_struct.c
nakilon has quit [Ping timeout: 240 seconds]
Ven has quit [Ping timeout: 240 seconds]
<jeromegn> asterite: apparently the SEEK_SET constant was removed from FileDescriptorIO, but it's still referenced here: https://github.com/manastech/crystal/blob/master/src/io/file_descriptor_io.cr#L245
<jeromegn> I'm not sure how to fix that, else I would've submitted a PR
<jeromegn> I can open an issue though
Ven has joined #crystal-lang
nakilon has joined #crystal-lang
willl has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vZPvu
<crystal-gh> crystal/master c714a78 Ary Borenszweig: Missing "$" for ExternalVar#to_s
Ven has quit [Ping timeout: 246 seconds]
<travis-ci> manastech/crystal#c714a78 (master - Missing "$" for ExternalVar#to_s): The build was broken. https://travis-ci.org/manastech/crystal/builds/80118839
Ven has joined #crystal-lang
<jhass> ?json_union
Ven has quit [Ping timeout: 268 seconds]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
blue_deref has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
<BlaXpirit> they pack float completely manually
kulelu88 has joined #crystal-lang
<jeromegn> ha!
<jeromegn> I mean, for now, just so my spec actually run and don't get a compile error, I swicthed it to Int64
blue_deref has quit [Quit: Taking myself out of hear.]
<Papierkorb> >> 0 as LibC::SizeT
<DeBot> Papierkorb: Error in line 4: can't cast Int32 to UInt32 - http://carc.in/#/r/f3h
<jhass> >> LibC::SizeT.cast(0)
<DeBot> jhass: # => 0 - http://carc.in/#/r/f3i
<Papierkorb> jhass: just tried that because I see the as keyword used elsewhere, so that would be consistent to me
<jhass> I should try to get cast renamed
<jhass> it's conversion actually, not casting
Neverdie has quit [Quit: http://radiux.io/]
<jhass> invokes the right .to_x on the argument based on the receiver
Neverdie has joined #crystal-lang
<willl> I've held of on suggesting that https://github.com/will/crystal-pg/blob/master/src/core_ext/class.cr gets added to the language mostly because of the awkward name. if the current cast was named something different that'd be nice. Though I'm not sure what to change it to
<jhass> convert is too long, maybe from or conv
<willl> hm, convert might not be too long
<jhass> from gives nice symmetry with to_x IMO
<willl> yeah that's a good point
<BlaXpirit> could even be called `new`
<BlaXpirit> yes, `cast` is not good
jeromegn has quit [Ping timeout: 252 seconds]
<jhass> mmh, new is not a bad idea too
Ven has joined #crystal-lang
<BlaXpirit> especially looking at things like String.new(pointer)
nakilon has quit [Ping timeout: 255 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
toydestroyer has quit [Remote host closed the connection]
toydestroyer has joined #crystal-lang
<asterite> "from" sounds good, better than "cast" and same amount of letters :)
apt-get has quit [Remote host closed the connection]
<asterite> And the "as_cast" is a pretty nice trick, I guess it's the same as "x as Int32" but you can do it with a runtime value?
<asterite> Like, a = Int32; a.as_cast(1) ?
<willl> asterite: regarding as_cast, yes. in crystal-pg you can pass in the types you want out, and the query, and then it does the as cast, to avoid union types.
<jhass> asterite: the more I think about it the more does using new grow on me, and it's even shorter. But at the end of the day I'd even live with convert, I just want to get rid of cast
<asterite> "new" can work too, yes. The problem is that "new" (and "initialize") are special for the compiler, because the lookup rules are slightly different
<asterite> It's a bit long to explain here, but it's because they play a role in determining nilablility of fields
<asterite> On unrelated news, we continued working on https://github.com/manastech/crystal_lib with waj
<jhass> yeah I saw the commits, nice progres
<asterite> You can try running src/main.cr and see what it prints. The idea is to simplify a lot the way to write C bindings, which right now is pretty boring and bug prone
<asterite> but right now it only works on mac. Oh, and we'll integrate that into the compiler, it won't be a separate tool :)
<asterite> But this week waj told me he'll also like to review the many pending pull requests, so we hope to get the count down
<jhass> that's good
<jhass> back to cast, is there a specific problem you see if we'd just rename the current cast methods to new?
<asterite> We also want a way to have a lib next to a .c/.h file and some way to compile and link that in an easy way, so you can write C code, mostly for interop, not so much for performance
<asterite> We can try with "new" and see what happens
<asterite> But check this: http://play.crystal-lang.org/#/r/f3n
<asterite> I don't know why that doesn't work, might be a bug or something related to "new"... but if it's called "from" it works
<asterite> But since that "new" will be in every leaf type (Int32, etc.) it might not be a problem
<jhass> let's see
BlaXpirit has quit [Quit: Konversation]
havenwood has quit [Ping timeout: 244 seconds]
<crystal-gh> [crystal] jhass opened pull request #1465: Rename the cast class method to new (master...no_cast) http://git.io/vZPQ6
[spoiler] has quit [*.net *.split]
lokulin has quit [*.net *.split]
[spoiler] has joined #crystal-lang
lokulin has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vZPbt
<crystal-gh> crystal/master c94c5a7 Ary Borenszweig: Fixed #1463: SEEK_SET still references in FileDescriptorIO
<crystal-gh> crystal/master 42690c4 Ary Borenszweig: Fixed #1455: incorrect length returned in XML parse IO callback
ponga has quit [Quit: Connection closed for inactivity]
Raimondi has quit [Ping timeout: 264 seconds]
<crystal-gh> [crystal] asterite closed pull request #1465: Rename the cast class method to new (master...no_cast) http://git.io/vZPQ6
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vZPp2
<crystal-gh> crystal/master a590c6e Ary Borenszweig: Changed a few "cast" to "new'
<travis-ci> manastech/crystal#8142f08 (master - Merge pull request #1465 from jhass/no_cast): The build was broken. https://travis-ci.org/manastech/crystal/builds/80155353
lokulin has joined #crystal-lang
lokulin has quit [Changing host]
<travis-ci> manastech/crystal#a590c6e (master - Changed a few "cast" to "new'): The build passed. https://travis-ci.org/manastech/crystal/builds/80155417