<asterite>
That's because getters might not be available for some fields
<jhass>
I see instance_variable_get/set so abused in ruby, would really like to see it private
<asterite>
so it's like Ruby's instance_variable_get
<asterite>
Yes, I think that too
<asterite>
I'll leave clone like that for now until we have "instance_variable_set", and then we can implement it like that (with the added visibility check)
<asterite>
I'm trying to remove the standard library classes, but I don't know how much further I can go
<jhass>
line 16 can be a plain get actually
<asterite>
One line: -> { ({} of String => String).map {|key| key.to_s }.to_s }
<asterite>
:)
bcardiff has joined #crystal-lang
<jhass>
:o
<jhass>
that's weird
<jhass>
one would thing we would've hit that earlier :P
<jhass>
*think
<asterite>
Hehe, yes
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<asterite>
Well, the assertion is gone if I change the way Hash#map is implemented
<asterite>
I changed some Enumerable, Array and Hash methods to use typeof, but that's not quite right
<asterite>
so we'll change it back, which means the "can't infer block type" will come back (but less frequently, only if you use a free var as the output, not if you specify a type like HTTP::Response)
<asterite>
but I think for now that's better than the ugliness of typeof(ugly code)
havenn has joined #crystal-lang
havenwood has quit [Ping timeout: 264 seconds]
<asterite>
In any case, I'll fix the bug :)
<jhass>
yeah, I'm really curious if it the assertion just doesn't trigger in the full version and generated invalid code
weskinner_work has joined #crystal-lang
<weskinner_work>
I think I understand channel_primes.cr now :)
<weskinner_work>
If I understand correctly the 100.times loops creates a chain of filters and a prime is any number who makes it through all the filters. Or in other words, any number that isn't evenly divisible by any of the primes before it
waj has quit [Quit: Leaving.]
asterite has quit [Quit: Leaving.]
asterite has joined #crystal-lang
bcardiff1 has joined #crystal-lang
asterite1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 252 seconds]
asterite has quit [Ping timeout: 246 seconds]
orliesaurus has quit [Ping timeout: 265 seconds]
waj has joined #crystal-lang
orliesaurus has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff1 has quit [Ping timeout: 250 seconds]
shama has joined #crystal-lang
asterite has joined #crystal-lang
<asterite>
weskinner_work: exactly! But too me it's still black magic :)
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 246 seconds]
havenn has quit [Remote host closed the connection]
<weskinner_work>
:D
<asterite>
>> File.join("", ""); {1, 2}.max
<DeBot>
asterite: 2
leafybasil has quit [Remote host closed the connection]
ismaelga has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
<asterite>
jhass: good news, I debugged your code
<crystal-gh>
[crystal] asterite pushed 4 new commits to master: http://git.io/prxe
<crystal-gh>
crystal/master 20240b5 Ary Borenszweig: Fixed a bug related to untyped blocks
<crystal-gh>
crystal/master 9a027ad Ary Borenszweig: Fixed: don't incorrectly bind vars to themselves after blocks
<crystal-gh>
crystal/master 7329543 Ary Borenszweig: Fixed a bug regarding included generic modules
<jhass>
\o/
<asterite>
I found like three errors, and one of them was totally screwing the type inference
<jhass>
:D
<jhass>
you're welcome :P
<asterite>
That's why it was probably crashing, because the generated code was basically wrong wrong :)
<asterite>
Now your code almost compiles, you have to specify just one block type, but where to do that is clearer now
<jhass>
alright, I'll try right away, thanks so much!
<asterite>
As always, these "can't infer block type" might be gone one day, maybe...
<asterite>
No, thank you! We need more programs that catch these kind of bugs
<jhass>
cool, even fixed one of the can't infer block types I still had, so just traded one for another :P
<jhass>
I'll keep it running for a couple of hours and then push the latest version
<asterite>
The "can't infer block type" now only happens if it's something like &block: -> T, where T is a free variable (like in the case of Enumerable#map), but when it's, say, &block : -> HTTP::Response, it will never give that error
weskinner_work has quit [Remote host closed the connection]
anatolik has joined #crystal-lang
havenwood has joined #crystal-lang
weskinner_work has joined #crystal-lang
bcardiff has joined #crystal-lang
<havenwood>
asterite: Looking to fix my PR for #each_slice and I think I need some guidance. In Ruby `[1, 2, 3].each_with_index.to_a #=> [[1, 0], [2, 1], [3, 2]]` and `[1, 2, 3].each_slice(2).to_a #=> [[1, 2], [3]]` (they return Enumerators hence the #to_a).
<asterite>
Yes... we don't have Enumerators yet
<asterite>
Well, we have Iterator, which is similar, but very experimental
<havenwood>
asterite: So for now better to return nil than Arrays?
<asterite>
Yes
<havenwood>
Roger that, will do. Thanks!
<asterite>
Just yesterday we were playing with iterators and Enumerable... we managed to create one out of any Enumerable by using spawn and channels (in a way similar to Ruby, I guess)
bcardiff1 has quit [Ping timeout: 246 seconds]
<asterite>
but it's slow, of course
<asterite>
We toyed with the idea of creating enumerators like in C#, but that is one big task which for now I don't think we'll do
<asterite>
(by the way, it's slow but faster than Ruby)
<crystal-gh>
[crystal] asterite pushed 4 new commits to master: http://git.io/poy7
<crystal-gh>
crystal/master 050f6b6 Ary Borenszweig: Fixed: wasn't able to write a call block argument after named arguments
<crystal-gh>
crystal/master 64a90a8 Ary Borenszweig: Macro vars can be indexed with expressions (%var{a, b})
<anatolik>
Have you tried using Crystal with recently released LLVM3.6?
waj1 has joined #crystal-lang
<weskinner_work>
asterite: can you explain the difference between and iterator and enumerator?
waj has quit [Ping timeout: 252 seconds]
<asterite>
Not yet, it was released some weeks ago (I think) but it's not yet in popular repositories (like homebrew)
<anatolik>
The reason I ask is that Linux Arch is going to have 3.6 in [testing] repository soon (maybe even today)
<asterite>
weskinner_work: they are the same, just different name because Enumerator is magical in Ruby and Iterator is a module and you must include it and implement `next` (super experimental, uses exceptions for control flow, ugly!)
<asterite>
weskinner_work: check iterator.cr and iterator_spec.cr