develooper Front page | perl.perl6.language | Postings from May 2005

Quick question: '1.28' * '2.56'

Thread Next
From:
Autrijus Tang
Date:
May 17, 2005 06:05
Subject:
Quick question: '1.28' * '2.56'
Message ID:
20050517130419.GA34648@aut.dyndns.org
Imagine:

    pugs> '1.28' * '2.56'
    3.2768

What is (or should be) going on here here?

[1] role NumRole {
	method infix:<*> returns Num (NumRole $x, NumRole $y: ) { ... }
    }
    Str.does(NumRole);

[2] multi sub infix:<*> (Str $x, Str $y) returns Num { ... }

[3] multi sub prefix:<+> (Str $x) returns Num { ... }
    multi sub infix:<*> (Num $x, Num $y) returns Num { ... }
    multi sub infix:<*> (Any $x, Any $y) returns Num { +$x * +$y }

[4] multi sub infix:<*> (Num $x, Num $y) returns Num { +$x * +$y }
    # ...and the MMD dispatcher forces incompatible type into
    # the type with shared ancestors and closest distance...

[5] none of the above -- that should be a type error. ;)

[6] something else?

Thanks
/Autrijus/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About