|No such thing as a small change|
Abusing attributes (possible perl bug?)by acid06 (Friar)
|on Feb 08, 2006 at 03:05 UTC||Need Help??|
acid06 has asked for the
wisdom of the Perl Monks concerning the following question:
I'm planning on writing yet another module which handles/enforces class interface contracts (e.g. public/private method and the like). My motivation is that none of the currently existing ones handle everything I want with a really simple interface. Class::Meta came close but I really think its interface is somewhat verbose.
Anyway, I came up with the idea of using subroutine attributes for this interface. Now, I know some of you might be screaming "that's the weirdest idea ever". But just forget the concept for now and focus on the implementation, since that's the point of this question.
I coded a really simple test class that would handle the "DEFINITION" subroutine attribute and would just print whatever it got. Just for testing.As you can see, the attribute name now got changed to INITION. It seems to be overwriting itself somehow.
That's all sweet and dandy and if I say:
I succesfully get this printed: UNIVERSAL::DEFINITION: main GLOB(0x283179c) CODE(0x225454) DEFINITION whatever CHECK
Now comes the tricky part.
I think the code below should work. But it doesn't. I don't know if there's an obvious mistake and I'll be ashamed for eternity for ever writing this node. But I truely believe it's some kind of perl bug, but I hope to be wrong. Here's the code:
When it runs I get this error message:
Do you see something wrong there? The attribute name got changed to pub_mt1, which is a substring of the attribute parameter.
But wait, there's even more weirdness. If I strip some lines off the code, so that it ends up like this:
I get this as an error:
I find this all too weird. Any help or advice would be appreciated.
perl -e "print pack('h*', 16369646), scalar reverse $="