Steffen Schwigon ha scritto:
gabriele renzi <[EMAIL PROTECTED]> writes:
I solved the (easy) problem 32, implementing gcd($a,$b).
You can check the code in the repository or on the web
I looked at . What's the purpose of "multi" in this case?
(Maybe you wanted to write it as more than one subs, did you?)
look the comment:
# Yet, it should be possible to define it even for commutative rings
# other than Integers, so we use a multi sub.
I think that in these examples we should respect the old good
programmin' habits, including the "stay open for extension" idea.
If we'd use a normal sub we would limit all the future user of gcd
(which I expect to be legions ;) to using Int.
Could someone explain me what is the expected behaviour?
Last time I experimented with this, the type system in Pugs looked
unfinished. Type constraints were syntactically accepted but worked
similar to typeless code in Perl5. I'm not sure about the current
Anyway, in your example I hadn't expected a value coercion (from 10.1
to 10), but something like an error if the type doesn't match.
this is what I'd like to see too, since I think it could help avoiding
casual errors, and the extensibility of the system is still safe because
of the multi things.
But I remember reading that, by default, perl6 will try to autocoerce
blog en: http://www.riffraff.info
blog it: http://riffraff.blogsome.com
jabber : rff.rff at gmail dot com