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

Re: Quick question: '1.28' * '2.56'

Thread Previous | Thread Next
From:
Larry Wall
Date:
May 17, 2005 10:51
Subject:
Re: Quick question: '1.28' * '2.56'
Message ID:
20050517175128.GA21062@wall.org
On Tue, May 17, 2005 at 09:04:19PM +0800, Autrijus Tang wrote:
: 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?

I tend to think of it most like [3], but it's possible that it's the
same as [1] if the role is supplying the coercion assumed in [3].

Larry

Thread Previous | 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