The stupid question is the question not asked | |
PerlMonks |
Re: Cannot overload ++ when the object is accessed via Attribute -> Tie -> Classby Anno (Deacon) |
on Oct 03, 2007 at 13:19 UTC ( [id://642396]=note: print w/replies, xml ) | Need Help?? |
My, my my. Overload, wrapped in a tie, wrapped in an attribute. That doesn't make debugging easier. If you have trouble with such a setup, you need to peel back the various layers and test each one separately, first overloading, then the tie interface, then the attribute wrapper.
I wonder whether there is a way to overload the ++ operator or not. The increment operator *is* overloaded as systematic testing shows. The problem is that the TieStringifiableInteger::STORE method is called with the stringified version of the new value instead of the numeric one. (No, I don't know offhand why that happens.) Change it to That forces the numeric value and fixes the error. As a side note, is there a reason why two of the overloading functions ('""' and '0+') are named methods but '++' is implemented anonymously? What is your opinion on such a module? Is it worth uploading to CPAN? A note; I am designing to module to add stringification for different languages. In my view, the module has an overly involved interface to call a function automatically that would better be called explicitly from case to case. The basic function (converting numbers to strings) is already covered by CPAN modules for various langiages, including Turkish (Lingua::TR::Numbers) Anno
In Section
Seekers of Perl Wisdom
|
|