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

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

Thread Previous
Luke Palmer
May 17, 2005 06:35
Re: Quick question: '1.28' * '2.56'
Message ID:
On 5/17/05, Rob Kinyon <> wrote:
> > Maybe s/Num/NumLike/ or something?  Anyway, that's how I think of it
> > at least: not that a Str is converted into a Num, but rather that
> > certain Strs are Nums.
> If that's the case, then if I change a variable that isa Str (that isa
> Num), does it change what it inherits from?

Er, Str is not a Num.  Num is a subtype of Str, so Num is a Str.  If
you change a Str, it could cease to be a Num.

    $x = "123";    # $x does Str & Num & Int
    $x .= ".45";   # $x does Str & Num
    $x .= "xyz";   # $x does Str

But again, don't take this as gospel.  This is just a tidbit from the
object model which I will probably not end up proposing.  I find it
quite elegant when used with pure (as in, non-manhattan) MMD.  It
doesn't really make sense with manhattan-style, since we can't
determine what a "level of inheritance" is with subtypes.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About