tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tomchapin has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<asterite>
jiriki: oh, it looks like ruby in a lot of ways, but it's definitely not ruby
shama has joined #crystal-lang
<smarr>
Hi, I am trying to create a tree of arrays, is there any way to type that?
dylanmei has joined #crystal-lang
shama has quit [Read error: Connection reset by peer]
shama has joined #crystal-lang
<asterite>
smarr: maybe define a class Tree(T) with a children property that's an Array(Tree(T))?
elia has quit [Quit: Computer has gone to sleep.]
<asterite>
smarr: another way is to use a recursive alias, but the alias can't be generic
<smarr>
asterite: hm, well, all I need is essentially Array(Array(recurs)?), it is not really for a practical application, just few lines of toy code
<smarr>
asterite: found it in the docs, will try alias
<smarr>
asterite: that helped, thanks!
<asterite>
Great! :-)
<smarr>
do I need to indicate via type hints that a class has virtual methods? the compiler tells me sometimes that the inferred type is `AbstractThing+` so, do I need to use that as well? I saw docs with an add method where the arguments where typed as Number without `+`
acetoxy has joined #crystal-lang
alsm has quit [Ping timeout: 256 seconds]
<asterite>
The `+` is an internal thing and shouldn't be used, we'll soon remove it
<asterite>
All methods are virtual by default and there's no way to make them final
trapped has joined #crystal-lang
<smarr>
ok, strange thanks. One of the issue I was seeing was that an 'abstract' method was called (with a raise) instead of a concrete one, thought that might have been related
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mondok has joined #crystal-lang
<asterite>
smarr: don't know, would have to see some code to understand
<jiriki>
asterite: yeah because I'm thinking of learning rust
<jiriki>
crystal is alternative
<BlaXpirit>
jiriki, you can also start learning rust, see that it's hopeless, and then learn crystal
<jiriki>
heh
<jiriki>
does crystal have
<BlaXpirit>
i've tried to learn rust 3 times so far
<jiriki>
ah nvm
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
tomchapin has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
<smarr>
ok, so, I am still having this problem: in a class hierarchy, an 'abstract' method gets called, while a method of one of the subclasses should be called
<smarr>
and the method that is called is AbstractConstraint.inputs_do instead of UnaryConstraint.inputs_do
<smarr>
the concrete subclass instantiated is StayConstraint.
<smarr>
The code should be fine, it types check, and otherwise is identical to its Ruby version
<smarr>
and ideas/suggests how do debug this would be appreciate
<asterite>
smarr: it would be nice if you could reduce the code a bit
<asterite>
smarr: and a method that raises is not abstract in crystal, an abstract method in crystal is `abstract def ...`
<Papierkorb>
asterite: Have you ever considered adding a 'const' keyword, to guard variables from write access?
<Papierkorb>
Pendant to C/C++'s const
<asterite>
Mmm... no, I don't find that very useful
<asterite>
if you don't want to write to a variable, just don't write to it. If you write to it by mistake then a test will probably fail, or the app will fail in some point
<Papierkorb>
I really don't like that when you have some method you've never seen before, that you'd have to read it, and actually all of the underlying methods too, to know if it will mess with your data structure you're passing in
<asterite>
smarr: I don't quite agree with those specs "are we fast yet", they create their own Vector type, but that's slow, Array is fast because it's implemented on top of Pointer. Vector should be Array
<asterite>
Oh, but that's different from a const variable, that's a const data structure... that would make everything much more complex, I'm sure
<asterite>
like how it's done in D with const/immutable
<Papierkorb>
Never used D, 'only' C/C++
<Papierkorb>
The most important part in that was probably being able to declare a method being 'const', a contract saying "i won't modify the value of 'this->'"
<asterite>
smarr: how to run that deltablue?
<Papierkorb>
I'm really missing such a feature in other languages like ruby (okay, scripting language, completely dynamic et al) or Java (no excuse here IMO)
<smarr>
asterite: thanks for the pointer to abstract methods, looks like it is an issue with not matching signatures
<asterite>
smarr: if you declare them as `abstract def output`, `abstract def choose_method(mark)`, then later if you fail to implement them the compiler will give you an error :-)
<smarr>
asterite: yepp, it is doing that now, thanks
<asterite>
Papierkorb: well, actually, waj wants to have const, I think. Maybe in the future we'll have it? I don't know. For me it will complicate things a lot, because most aren't interested in const, but if you have it then everyone will have to learn it
<smarr>
asterite: and with respect to Vector, I am not interested in comparing different Vector implementations, or language-specific semantics of Array, I am interested in comparing compiler efficiency. So, fixing what Vector is removes one variable from the equation
<asterite>
I see. Well, once you have results, please share them! We always like benchmarks and knowing what we can improve
<smarr>
hm, so, what does the signature need to look like to pass a block? abstract def inputs_do(&block)?
<smarr>
if I have `def inputs_do(&block)` in the subclass, the compiler still complains
<Papierkorb>
asterite: Should I open a PR or is there some ML or is it out of scope atm?
<Papierkorb>
Err, I meant a GH issue, not PR ;)
<asterite>
smarr: `def inputs_do(&block)` should work, I just tested it and it works
<asterite>
or just defining a method that yields (without needing &block)
<asterite>
Papierkorb: an enhancement request for const?
<Papierkorb>
asterite: Correct
<asterite>
You can send one, but it should say how it works in every case, how the syntax changes and what's the semantic of it
<Papierkorb>
k, thanks
<smarr>
hm, strange, adding types to the block helped
<smarr>
bye the way, does Crystal do any kind of dynamic compilation? I saw unexpected speedups after 260 something iterations of a benchmark
ssvb has joined #crystal-lang
Excureo has joined #crystal-lang
matp has quit [Remote host closed the connection]
<Papierkorb>
Huh, I'm now receiving spam because my Github account is somehow associated with Crystal Oo
<Papierkorb>
> I’m on the software development research team at [REDACTED], [...]. We’re collecting small stack samples from Crystal developers, [...].