|go ahead... be a heretic|
Using constant to override (abstract) methods.by klekker (Pilgrim)
|on Mar 28, 2011 at 08:29 UTC||Need Help??|
klekker has asked for the wisdom of the Perl Monks concerning the following question:
Dear fellow monks.
In a recent project I used an abstract base class as an interface and implemented its abstract methods using constants (for the sake of clarity; please see my code below).
Reading the docs for 'constants' I can't see anything wrong with this usage (constants become inline functions at compile time and I can override functions).
Now a colleague claims that I cannot rely on this behaviour because constants become *inline* functions and so the lookup might crash in some (unknown?) cases.
Well, the code works. But since it is supposed to run on a customers system and I don't want to have to fix it later if we run into trouble, I've decided to approach a higher instance:
so esteemed monks let me please ask you: is this approach okay or do you see any problems?
Or better: is this implementation considered harmful?
Thanks in advance!
This is a Text aaa, bbb, ccc Son:This is a Text Son: aaa, bbb, ccc