help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing arguments to macros


From: Paul D. Smith
Subject: Re: Missing arguments to macros
Date: Mon, 18 Nov 2002 13:34:02 -0500

%% Robert Mecklenburg <address@hidden> writes:

  PDS> So.  The question is, would it be a good idea for an invocation
  PDS> of call to "blank out" all the variables (by declaring that
  PDS> variable with the empty value in the innermost scope before
  PDS> expanding the function)?

  rm> If you're asking my opinion, then "yes".

Heh :).  Yes, I agree that on the surface it seems reasonable.  I was
really asking (myself, mostly) whether or not there are hidden gotchas
that might cause problems.  It turns out that due to make's highly
recursive method of expanding variables you can get some surprising
results.

For example, people wanted to be able to use conditionals within
functions, but right now all arguments to the call are expanded up-front
so the conditional doesn't work correctly (the arguments in the false
branch are always expanded anyway).  That seemed easy enough to fix:
just change the assignment of $1 et. al. from simple to recursive
assignment--but after implementing it I discovered that caused even more
problems due to the scoping of variables--you couldn't reliably nest
call invocations!


Offhand I don't see similar problems with this suggestion, but sometimes
you don't notice them until after you try it out :).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]