Hi!

gabriele renzi <[EMAIL PROTECTED]> writes:
> Hi everyone!
>
> I solved the (easy) problem 32, implementing gcd($a,$b).
> You can check the code in the repository or on the web[1]

I looked at [1]. What's the purpose of "multi" in this case?
(Maybe you wanted to write it as more than one subs, did you?)

> But while writing this I noticed that a function written as
>
>   sub gcd(Int $a, Int $b)
>
> still accepts float/rational values in input.
> I think I read once that a variable of type Int would accept these
> kind of assignment but that the value would be coerced to the new type
> of the variable, i.e.
>
>   my Int $a= 10.1 #=> 10
>
> 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
state.

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. But I
can't find the right place in the synopses to verify it.

Anyone with a clue here?

Steffen 
-- 
Steffen Schwigon <[EMAIL PROTECTED]>
Dresden Perl Mongers <http://dresden-pm.org/>
Deutscher Perl-Workshop <http://www.perl-workshop.de/>

Reply via email to