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

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

Thread Previous | Thread Next
From:
Sam Vilain
Date:
May 17, 2005 19:02
Subject:
Re: Quick question: '1.28' * '2.56'
Message ID:
428AA226.9020505@vilain.net
Larry Wall wrote:
> :     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);
> : [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 }
> 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].

I like #3, because it doesn't have any nasty implications to the type
calculus.

I don't really have the theoretical or practical knowledge to really be
able to back this up, but I have a strong hunch that value-based type
shifting is the type system equivalent of $&.

Sam.

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