On Thu, Sep 17, 2009 at 8:22 PM, Uri Guttman <u...@stemsystems.com> wrote:

> the strange way is because that is how perl does it. perl doesn't have a
> proper macro mechanism which is how many langs do constants. so it needs
> something that is parsed in perl and subs with empty prototypes work
> well. the compiler sees there are no allowed arguments (the empty
> prototype) and that the body is just a constant with no other code. this
> is then converted to a real compile time constant when used. it is wacky
> but it works. normally it is best invoked with the constant pragma but
> as slurp needs to be very backwards compatible i did it by hand. also
> there are other ways such as the readonly module which works with scalar
> vars so they can be interpolated (which constant subs can't).

Now that is *exactly* what I wanted to know: concise and clear
explanation of both how and why, thanks a lot.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to