static foreach and new identifier names

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jan 5 18:36:52 UTC 2018


On Fri, Jan 05, 2018 at 06:33:52PM +0000, Adam D. Ruppe via Digitalmars-d wrote:
> On Friday, 5 January 2018 at 18:07:54 UTC, H. S. Teoh wrote:
> > Simple solution: add another pair of {} to create a nested scope:
> 
> That's illegal outside of functions, though, which is the place static
> foreach is special!
> 
> Also, introducing a new scope means you can't expose that stuff to the
> outside world, which defeats the point. (I had tried doing that and
> using the alias outside but still fails.) Note that my declarations
> here are NOT temporary - the reason I'm trying to use static foreach
> is to introduce new public members to the scope.

What about my second idea of using a template to create new identifiers
for intermediate declarations?  That way, you can still introduce new
declarations to the outer scope that depend on these intermediate
declarations.


T

-- 
Truth, Sir, is a cow which will give [skeptics] no more milk, and so they are gone to milk the bull. -- Sam. Johnson


More information about the Digitalmars-d mailing list