Re: No overload magic

[prev] [thread] [next] [Date index for 2005/02/18]

From: Tim Bunce
Subject: Re: No overload magic
Date: 09:43 on 18 Feb 2005
On Fri, Feb 18, 2005 at 01:43:59AM -0500, Michael G Schwern wrote:
> On Thu, Feb 17, 2005 at 02:20:34PM +0000, William Ross wrote:
> > As far as I know == still works this way. The original poster was 
> > expecting > to be the same, which at the moment it isn't.
> 
> Why would only == be overloaded?  Why not just do <=> and let the fallback
> behaviors take care of the rest?

It should. Any cases where it doesn't are, in my view, a bug.

The goal is to hide (encapsulate) the effect of making a field a
foreign key. So if

	$obj->field_a

used to return an integer (or string) then one day is turned into
a foreign key to some other table, and so becomes a reference, all
the existing code that uses field_a will still 'just work'.

Tim.

> Though perhaps I answered my own question below...
> 
> > It's interesting to note that the overloading of == also means that
> > 
> > 	Class::A->retrieve($id) == Class::B->retrieve($id)
> > 
> > will be true, provided they exist. Is this good, bad or irrelevant?
> 
> Good point.  I'd be inclined to say that should be false.  We are talking
> about object equality here, not just the value of the primary key.
> 
> The only special case I can think of is this:
> 
> 	Class::A->isa('Class::B') || Class::B->isa('Class::A')
> 
> ie. if one is a subclass of the other.
> 

No overload magic
Karjala 07:55 on 16 Feb 2005

Re: No overload magic
Karjala 08:01 on 16 Feb 2005

Re: No overload magic
William Ross 10:05 on 16 Feb 2005

Re: No overload magic
Michael G Schwern 11:25 on 16 Feb 2005

Re: No overload magic
Tony Bowden 14:10 on 16 Feb 2005

Re: No overload magic
William Ross 14:20 on 17 Feb 2005

Re: No overload magic
Michael G Schwern 06:43 on 18 Feb 2005

Re: No overload magic
Tony Bowden 08:21 on 18 Feb 2005

Re: No overload magic
Tim Bunce 09:43 on 18 Feb 2005

Re: No overload magic
Karjala 11:57 on 16 Feb 2005

Re: No overload magic
William Ross 13:52 on 16 Feb 2005

Re: No overload magic
Karjala 14:09 on 16 Feb 2005

Re: No overload magic
Michele Valzelli 11:59 on 16 Feb 2005

Re: No overload magic
Ofer Nave 21:53 on 16 Feb 2005

Re: No overload magic
Ken.Olstad 22:00 on 16 Feb 2005

Generated at 11:20 on 20 Feb 2005 by mariachi v0.52