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

Can I OVERLOAD the assignment operator? Please???

Thread Next
John Peacock
May 22, 2003 07:05
Can I OVERLOAD the assignment operator? Please???
Message ID:
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:

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):

so I have something to start working with...


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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About