e_dub has joined #crystal-lang
e_dub has joined #crystal-lang
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> [travis-ci] Build details : http://travis-ci.org/manastech/crystal/builds/25233843
<travis-ci> [travis-ci] manastech/crystal#1063 (master - 785862d : Ary Borenszweig): The build passed.
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> [travis-ci] Build details : http://travis-ci.org/manastech/crystal/builds/25234830
<travis-ci> [travis-ci] manastech/crystal#1064 (master - 614bc09 : Ary Borenszweig): The build passed.
waj has joined #crystal-lang
CraigBuchek has joined #crystal-lang
waj has joined #crystal-lang
bcardiff has joined #crystal-lang
waj1 has joined #crystal-lang
asterite has joined #crystal-lang
e_dub has joined #crystal-lang
bcardiff1 has joined #crystal-lang
waj has joined #crystal-lang
asterite has joined #crystal-lang
asterite_ has joined #crystal-lang
rudy_ has joined #crystal-lang
<Guest13875> hi, on the github wiki there is a section describing Type instantiation caching https://github.com/manastech/crystal/wiki/Developers#type-instantiation-caching ; in the second code example `generic` is being useed as if it is a keyword however upon trying to compile the example on my local machine the compiler throws an error identifying`generic` as a missing method.
<asterite> Hi @Guest13875 , that page is *really* outdated
<Guest13875> Could someone give me a little more direction on type instantiation caching and how to declare a class as generic
<Guest13875> ?
<asterite> I think we should delete it, because everything it says is like… it was like that one year ago :)
<asterite> Sure
<asterite> You can take a look at the Array class: https://github.com/manastech/crystal/blob/master/src/array.cr
<asterite> but basically, you do: class MyClass(T)
<asterite> or more parameters: class MyClass(A, B)
<asterite> then you can use T as type restrictions
<asterite> and to instantiate: MyClass(String).new
<asterite> (or T can be deduced if it’s in the initialize method)
<asterite> What are you trying to do?
<Guest13875> I'm just starting to get familiar with the language and trying to get a handle on what's going on with type-instantiation caching
<asterite> Good. But type-instantiation caching is just a compiler strategy, it shouldn’t matter to a user of the language
<asterite> We still need to document the language in the standard library… we hope soon to “release” 0.1.0 (just to put a version to it once and for all) and maybe start documenting things and slowly adding more features/fixings bugs until we reach 1.0.0 (still way in the future)
<Guest13875> What about when I'm defining my own custom classes?
<asterite> Everything should work in a way very similar to Ruby
<asterite> Do you program in Ruby?
<Guest13875> Cool!
<Guest13875> I do program ruby
<asterite> You can try to write a small program as you would in Ruby and we can help you get around the differences or explain the error messages
<Guest13875> Awesome, that's great to hear
<Guest13875> Hey why are ranges declared with spaces before and after the operator e.g. `(0 .. 10)` instead of `(0..10)` as in ruby?
<asterite> It works in both ways
<asterite> where did you see it?
<asterite> (in ruby it also works in both ways, the spaces are optional)
<Guest13875> Oh yeah you're right, I've been using at the spec kind of like documentation https://github.com/manastech/crystal/blob/master/spec/std/range_spec.cr
<asterite> It’s true, it looks too spacey :)
e_dub has joined #crystal-lang
<Guest13875> Ok looking more at array.cr what does `def initialize(size, value : T)` do? specifically `value : T`? Does that set `T` to the type of `value` if a type restriction is not passed upon initialization?
<asterite> Yes, more or less
<asterite> You can do: Array(Int32).new(10, 1)
<asterite> and that will compile, since T here is Int32 and 1 has type Int32
<asterite> If you do: Array(Int32).new(10, “hello")
<asterite> that won’t compile since value (“hello”) must be T (Int32) but it was a String
<asterite> And then if you do: Array.new(10, 1)
<asterite> that will also work, and T will be inferred to be Int32
<Guest13875> Is the syntax `value : T` applicable anywhere other than declaring methods?
<asterite> No, it’s only used to restrict the type of a method argument
<asterite> that way you can also have different method definitions with the same name but different types (unlike Ruby)
<Guest13875> So for example I could set up multiple initialize methods which get called accordingly to the type of the value passed in?
<asterite> Yes
edub has joined #crystal-lang
<Guest13875> Cool, this is really helpful. I need to get back to work but I'd like to build out some documentation on all this later today (along with other components of the language as I figure them out in the future). Would you folks mind if I put it on the crystal wiki? https://github.com/manastech/crystal/wiki
<asterite> Sure, no problem. Eventually all the documentation will be in a single place (there’s this, but it’s just a start: http://crystal-lang.org/docs.html )
<Guest13875> Awesome, thanks again for your help.
waj1 has joined #crystal-lang
asterite has joined #crystal-lang