[Dancer-users] Changing config hashref directly (was: Re: Dancer::layout has been deprecated)

damien krotkine dkrotkine at gmail.com
Mon May 23 11:11:16 CEST 2011

On 22 May 2011 13:46, David Precious <davidp at 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 at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110523/74739017/attachment.htm>

More information about the Dancer-users mailing list