<asterite>
We can do with modules just fine, but classes usually have a constructor and the mental model is different, plus the compiler treats a class hierarchy different than just included modules
<jhass>
it's just they feel so redundant to modules...
<asterite>
I don't know... in the compiler we have a base class ASTNode from which all nodes inherit
<asterite>
I would feel it weird if it were a module included by other classes
<asterite>
but maybe just because I'm used to model things like that
<jhass>
it wouldn't to me
<jhass>
yeah, it's because other languages don't have the module
<jhass>
I think
<asterite>
So Number would be a module too?
<jhass>
yup
<jhass>
I know its a class in ruby
<jhass>
but IMO conceptually a class is a specialization of a module
<jhass>
a class is a module of which you can create instances
<jhass>
so you want a class that you can't have instances of? -> take a module
<jhass>
that's an easy rule of thumb I use to explain when to use a class or a module to people new to ruby
canhtak has quit [Quit: canhtak]
<asterite>
I'll have to try and see what happens if I remove "virtual types" from the language, see if it's still fast to compile
<asterite>
With that I mean, right now if you have a union B | C, where B < A and C < A, the compiler treats it as A+
<asterite>
and that simplifies some things
<jhass>
what if we allow inheritance from a module and that turns it into a virtual type?
<asterite>
Well, the problem is that you can find many roots like that
<asterite>
but with classes you can only find one
<asterite>
I know it's an implementation detail that leaks into the language... that's why I'd like to try and see if it's still fast without that rule
<jhass>
module A; end; class B < A; end; A becomes A+; module A; end; class B; include A; end; A is a regular module like now
<asterite>
The thing is, we added that rule back when the compiler was written in Ruby, which was very, very slow, and that sped up things a lot
<jhass>
yeah, I'm looking at this purely conceptual, if it's not feasible implementation wise for whatever reason I can live with that
<asterite>
Of course I'd like the purest language if possible :)
<jhass>
>> module A; abstract def foo; end; class B; include A; end;
<asterite>
(although right now it's far from that, but at least we try to be close, but it's hard with a compiled language... Ruby has it soo easy)
<DeBot>
jhass: Sorry, that took too long.
<jhass>
heh
<jhass>
>> module A; abstract def foo; end; class B; include A; end;
<DeBot>
jhass: nil
<jhass>
mmh
<jhass>
>> module A; abstract def foo; end; class B; include A; end; B.new
<DeBot>
jhass: #<B:0x883FFF8>
<jhass>
>> module A; abstract def foo; end; class B; include A; end; B.new.foo
<DeBot>
jhass: Error in line 3: abstract def A#foo must be implemented by B
<jhass>
interesting
<jhass>
>> abstract class A; abstract def foo; end; class B < A; end;
<DeBot>
jhass: nil
<jhass>
>> abstract class A; abstract def foo; end; class B < A; end; B.new
<DeBot>
jhass: #<B:0x9B15FF8>
<jhass>
okay it's the same though
<jhass>
I never noticed :D
<asterite>
What?
<jhass>
that abstract only fires if you actually call the method
leafybasil has quit [Remote host closed the connection]
<asterite>
Ah, yes... we might make it fire at the end of the compilation, a check, even if you don't invoke it
canhtak has joined #crystal-lang
leafybasil has joined #crystal-lang
<asterite>
but for now almost all things are lazy
<jhass>
anyway, ruby has many quirks, like the root #inspect is implemented in a C function called rb_obj_inspect in object.c, documented on Object but actually defined in Kernel
<jhass>
don't feel too bad ;)
<asterite>
:-P
<asterite>
I think maybe reusing Ruby's syntax and some semantic was not a very good idea
<jhass>
I think it is
<asterite>
because when you create a new languae you can define rules and people have no idea what the rules are before diving into it
<jhass>
it's what made it appealing to me
<asterite>
but in Ruby that mental model is pretty complete by now
<asterite>
so we change some things and people expect it to work like in Ruby
<jhass>
you write "Ruby inspired syntax", I think that hits the point quite well
<asterite>
Hehe, yes :)
<asterite>
If I say "C inspired syntax" people imagine braces and semicolons
<asterite>
but they don't think about the semantic
<asterite>
Maybe in Ruby it's different because it's so unique
<jhass>
any experienced Rubyist will actually know the shortcomings and quirks of the language quite well and actually be thankful if you don't repeat them
<jhass>
some people you need to remind that if they come with "but in Ruby..." but that's it
<jhass>
I think there's a net win really
<jhass>
modeling after an existing language gives the benefit of some problems solved already, you just need to reevaluate them instead of solving them again
<the_asterite>
I just looked at them. They look nice, but they store everything in a big hash of mixed types, I don't think that goes well in Crystal. Plus with option parser you choose where and how to deal with each option. But it's true that in Ruby those things don't matter much
<jhass>
well, do we have to store it that way?
<jhass>
the conversion could happen on access, similar to pull parser
<jhass>
or even be up to the caller really
<the_asterite>
maybe. I think for now option parser is good enough :)
<jhass>
yeah sure
<jhass>
gotta leave room for a library eco system anyway :P
the_asterite has quit [Ping timeout: 264 seconds]
weskinner_work has joined #crystal-lang
ismaelga has joined #crystal-lang
weskinner_work has left #crystal-lang [#crystal-lang]
wanderer has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
asterite has joined #crystal-lang
ponga has quit [Quit: Leaving...]
shama has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eli-se has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
eli-se has quit [Quit: Leaving...]
leafybas_ has joined #crystal-lang
leafybas_ has quit [Remote host closed the connection]
leafybasil has quit [Ping timeout: 264 seconds]
ismaelga has quit [Remote host closed the connection]