[CMake] lexical scoping

Brandon Van Every bvanevery at gmail.com
Fri Nov 2 17:23:25 EDT 2007


On Nov 2, 2007 5:08 PM, Brandon Van Every <bvanevery at gmail.com> wrote:
> On Nov 2, 2007 5:02 PM, KSpam <keesling_spam at cox.net> wrote:
> > Bill,
> >
> > > set(a "world")
> > > variable_scope_begin(a)
> > > set(a "hello")
> > > message(${a})
> > > variable_scope_end(a)
> > > message(${a})
> >
> > This would be a workable solution for me.  It would certainly be a step in the
> > right direction, especially if it is easy enough to implement.  [...]
> > The whole "begin ... end" construct gets to be tedious after a while.
>
> Once it's introduced, we're gonna get stuck with it.  Please don't
> just do what's expedient.  Do something that will increase the
> likeability of CMake.

Oh, and I don't want macros that provide scope for only 1 variable at
a time.  When I write a macro that's really supposed to be a function,
I've got lotsa variables that I don't want the outside world to see.
This ain't gonna happen in the real world:

variable_scope_begin(scratch_preamble)
variable_scope_begin(got_match)
variable_scope_begin(not_trail)
variable_scope_begin(empty)
# [...]
# my actual code, blah blah blah
# [...]
variable_scope_end(scratch_preamble)
variable_scope_end(got_match)
variable_scope_end(not_trail)
variable_scope_end(empty)

This is also leaving out the issue of whether macro argument names can
shadow each other.  I haven't really investigated that yet.  If they
can, then that's even more scopes to cook up.

The cure is no better than the disease.  I'm already using
splitonlastword_ disambiguators.  In a short function, I'd still be
typing a similar number of extra characters and it would still be a
PITA.


Cheers,
Brandon Van Every


More information about the CMake mailing list