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

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

Thread Previous | Thread Next
Nick Ing-Simmons
May 23, 2003 00:37
Re: Can I OVERLOAD the assignment operator? Please???
Message ID:
John Peacock <> writes:
>Dan Sugalski wrote:
>> 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.
>So that is a vote in favor???  ;~)
>As I understand it, the reason you cannot mix your magics is that overload only 
>operates on RV's, so there is no magic table to lookup the set magic callback 
>from.  There is no reason to *fully* emulate tie, since there is already a get 
>magic (overload stringify/numify) that covers that case.

The way normal magic should work is that if a value is (tied) a variable
then mg_get() needs to be called if necessary to get the "value" then 
the magic on the returned value fires the overload. overload then does
its stuff and then mg_set gets called to store value back into variable.

IIRC something somewhere was looking at something "too early" or 
expecting its magic to be at front of MG * list.

Nick Ing-Simmons

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