Feature Request: throwing an exception when assigning to the CONSTANTS hash

David Turland <[email protected]> Fri, 17 May 2013 22:23:28 +0100
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
Hi,
It would be useful if assigning to the CONSTANTS hash in a template 
could be caught, maybe under STRICT or DEBUG options

e.g:
-------------------------------------------------
...
my $tt = Template->new({
     CONSTANTS   => {
       title       => 'A Demo Page',
     },
});
...
-------------------------------------------------
[% constants.title  %]

[% constants.title = "wibble" %]

[% constants.title  %]
-------------------------------------------------
which tt2 tolerates with narry a wimper :
-------------------------------------------------
A Demo Page

A Demo Page
-------------------------------------------------

DEBUG gives some clues:
...
$stash->set(['constants', 0, 'title', 0], 'wibble');
...

Obviously, 'constants' can be altered by CONSTANTS_NAMESPACE which Stash 
would now be interested in.
Else an extra check in Stash::set might_just_do_it...?

This cropped up as, in the pursuit of performance, I can probably move 
nearly 100% of the template variables to CONSTANTS.
With exceptions, to catch the exceptions, this could be as 
straightforward as the previous move to STRICT.

Thoughts and suggestions welcome,

Regards,

David T