develooper Front page | perl.perl5.porters | Postings from May 2003

Re: Can I OVERLOAD the assignment operator? Please???

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
May 23, 2003 00:31
Subject:
Re: Can I OVERLOAD the assignment operator? Please???
Message ID:
20030523073100.1643.4@bactrian.elixent.com
Dan Sugalski <dan@sidhe.org> writes:
>At 5:24 PM -0400 5/22/03, John Peacock wrote:
>>Dan Sugalski wrote:
>>>You already can overload the assignment operator. That's what tie is.
>>>
>>>Overloading as it stands now works on the value, while tying works 
>>>on the variable. (a contents vs container thing) Overload is a 
>>>value thing, tying a container thing. Assignment is an operation on 
>>>the variable rather than the value, so it should live in the world 
>>>of tying, not overloading.
>>
>>But I need both overloading (to automatically handle the comparison 
>>operators) _and_ tie (to prevent the overloaded magic from being 
>>lost through simple assignment).  Can I do both?  My initial tests 
>>show that I can use tie to manage set/get, but then I lose the 
>>overloading.
>
>That's something I think you can't do, and arguably a bug. I'm pretty 
>sure you can have tie magic, or overloading magic, but not both.

That is my recollection too.

I would quite like this fixed too - but it was tricky. I got 
as far as tracing the control path once.  


-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/


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