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

Can I OVERLOAD the assignment operator? Please???

Thread Next
From:
John Peacock
Date:
May 22, 2003 07:05
Subject:
Can I OVERLOAD the assignment operator? Please???
Message ID:
3ECCD913.8020707@rowman.com
As usual with my version object patches, the progress is always asymptotic.  I 
am so close, and yet so far! :~(

I have this working (and not):

	$VERSION = "1.2_3"; # version object, like new version "1.2_3"
	$VERSION = eval $VERSION; # now a scalar 1.23 :~(

This is a common motif, even in the ext/* files, though why an alpha module 
version should be permitted in any core file is beyond me.

I cannot seem to tell within vstringify() that I am inside the eval (it seems 
that entereval() doesn't set PL_in_eval).  I could just make version objects 
read only, but the thumping I'd get from the compatibility police wouldn't be 
pretty! 8~o

For the compatibility module (Perl < 5.9.0), I can use a source filter, but I 
obviously don't think that is going to fly for a core patch.  And I cannot use 
U-magic or ties, since then I'd lose the overloading of comparison operators.

So, before I start digging in the code, let's have the argument [again] why 
overloading the assignment operator is a bad thing.  Here's one thread:

http://www.xray.mpe.mpg.de/cgi-bin/w3glimpse2html/perl5-porters/1999-11/msg00465.html

and even better, there are a bunch of threads discussing Ilya Zakharevich's "my 
Dog spot and prepare" feature (which was not accepted for 5.6.0):

http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-12/msg00242.html
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-11/msg00882.html

so I have something to start working with...

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748


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