> Date: Thu, 12 Dec 2002 16:26:28 -0500 > From: John Siracusa <[EMAIL PROTECTED]> > > 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