Subject: Re: [Boost-docs] [quickbook] Template argument evaluation.
From: Joel de Guzman (joel_at_[hidden])
Date: 2009-05-29 13:26:37
Daniel James wrote:
> I've been going through some of the old template tickets, and having a
> look at the implementation and there's a few things which could be
> improved. I think that these changes should be activated by a version
> switch, so perhaps it's worth starting on a version 1.5.
> First, quickbook currently uses dynamic scoping which is generally
> accepted to be a bad idea. So I'd like to change it to use static
> scoping. This example:
> [template x static scoping]
> [template foo1 [x]]
> [template foo2[x] foo1]
> [foo2[dynamic scoping]]
> Will currently return 'dynamic scoping', I'd like it to change it to
> return 'static scoping' for 1.5 or whatever.
> When template arguments are expanded they are evaluated with the
> current scope rather than the scope they were called with which can be
> surprising. So I'd like to change it so that they are bound to the
> correct scope. So:
> [template x new]
> [template foo1[a x] [a]]
> [foo1 [x] old]
> Will return 'old' at the moment, I'd prefer it to return 'new'.
> Another way to achieve this would be to evaluate template arguments
> eagerly but that would be a much bigger change and harder to implement
> a version switch for. This change will fix this ticket:
> Does this sound okay?
Sounds good to me. Static scoping is indeed the way to go.
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
This archive was generated by hypermail 2.1.7 : 2017-11-11 08:50:41 UTC