On 22 May 2011 13:46, David Precious
<davidp@preshweb.co.uk> wrote:
On Saturday 21 May 2011 23:19:18 Naveed Massjouni wrote:
> Is config->{layout} = 'foo' the same as set layout => 'foo'?
In general, you shouldn't change the hashref returned by config(), but use
set() instead. Some settings, when changed via set(), trigger a hook to
handle that change (e.g. initialise a template engine when 'template' is used,
set up a catch-all route when 'auto_page' is used, etc). Changing them
directly, bypassing set(), means those triggers won't fire.
The 'layout' setting, however, doesn't have any trigger, so changing it
directly wouldn't hurt; I still wouldn't recommend it though, for future-
proofing.
In fact, it might make sense for us to change config() to return a tied hash
which emits warnings if you try to change any values, to discourage people
from using it to change settings directly, bypassing set().
That can be a good idea, but we should be extremely cautious with ties : they are slow, and a bit magic.
But a careful implementation can be the perfect solution in this case.
Cheers
--
David Precious ("bigpresh")
http://www.preshweb.co.uk/
"Programming is like sex. One mistake and you have to support
it for the rest of your life". (Michael Sinz)
_______________________________________________
Dancer-users mailing list
Dancer-users@perldancer.org
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users