Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Comparing Object Identity (was: Re: Stringification of refere nces (Decision, Please?)) [x-adr][x-bayes]

Newsgroups: perl.perl6.language
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.perl.org
Return-Path: <fibon...@babylonia.flatirons.org>
Mailing-List: contact perl6-language-h...@perl.org; run by ezmlm
Delivered-To: mailing list perl6-langu...@perl.org
To: sirac...@mindspring.com
Cc: perl6-langu...@perl.org
In-reply-to: <BA1E6934.28748%siracusa@mindspring.com> (message from John	Siracusa on Thu, 12 Dec 2002 16:26:28 -0500)
Subject: Re: Comparing Object Identity (was: Re: Stringification of refere	nces (Decision, Please?)) [x-adr][x-bayes]
References:  <BA1E6934.28748%siracusa@mindspring.com>
Message-ID: <20021213100908.62975349@babylonia.flatirons.org>
Date: Fri, 13 Dec 2002 03:09:08 -0700 (MST)
X-SMTPD: qpsmtpd/0.20, http://develooper.com/code/qpsmtpd/
Approved: n...@nntp.perl.org
From: fibon...@babylonia.flatirons.org (Luke Palmer)
Lines: 43

> Date: Thu, 12 Dec 2002 16:26:28 -0500
> From: John Siracusa <sirac...@mindspring.com>
> 
> On 12/12/02 4:01 PM, Larry Wall wrote:
> > On Thu, Dec 12, 2002 at 12:40:52PM -0600, Garrett Goebel wrote:
> > : So we'll _have_ to write $obj.*id when we mean $obj->UNIVERSAL::id;
> > 
> > If you wish to be precise, yes.  But $a.id eq $b.id should work for most any
> > class that uses the the term "id" in the typical fashion.
> 
> I still feel like we're talking past each other here.  What I was saying is
> that, regardless of any admonitions to the contrary, I think people will
> still write this:
> 
>     $a.id == $b.id
> 
> and expect it to compare memory addresses.  

And presumably, anyone who overrides .id in their own class knows what
they're doing.  They, in fact, I<want> statements like that to behave
that way.  Junction, by delegation, will override that method to
return a junction of the .ids of its states.

Speaking of which, how do you code delegation? 

    class Disjunction is Junction {
        has @.states is public;
        # ...
        # Use the class's AUTOLOAD?
        method AUTOLOAD($name, *@args) {
            any(map { $_.$name.(*@args) } @.states);
        }
        
        # Or use some kind of DELEGATE method, taking a curried
        # function with only the invocant left blank.
        method DELEGATE(&func) {
            any(map { $_.&func } @.states);
        }
    }

I rather like the latter.

Luke