NetBSD-Bugs archive

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

Re: bin/60850: Make could do with a syntax for immediate var expansion



The following reply was made to PR bin/60850; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/60850: Make could do with a syntax for immediate var expansion
Date: Tue, 06 Oct 2026 10:28:32 +0700

     Date:        Mon,  5 Oct 2026 11:10:01 +0000 (UTC)
     From:        "Valery Ushakov via gnats" <gnats-admin%NetBSD.org@localhost>
     Message-ID:  <20261005111001.777461A923C%mollari.NetBSD.org@localhost>
 
   |  A slighly less kludgy (but still kludgy) way to do that is to use the
   |  fact that the for-loop variables are expanded immediately:
 
 Ugh!   I'm glad I didn't know that (I actually believed that for-loop
 variables might be one of the types that could benefit from an "expand now"
 syntax) or I might have been tempted.   Truly horrible!
 
 But that does suggest an alternative resolution to this .. variables like
 .PARSEDIR .PARSEFILE (and all the other .name vars which make owns, which
 tend to vary - as distinct from those whick a knobs, or simply (for the
 session) constant values) could simply be made to ack like for loop
 variables, and simply be expanded on reference, always.
 
 That doesn't completely remove the uses for a syntax to get immediate
 expansion, but it does deal with the practical cases I know about (there
 could be others where a var is assigned to different values at different
 places, even something as simple as one of the xxFLAGS which get += all over
 the place, and where someone wants to capture the current state of
 such a variable, perhaps into a var that will contain a debug message
 to be output later, and which might already contain other var references
 which are not to be expanded until later.   So, some syntax to achieve
 this might still be nice, but my immediate need would be solved if all
 of these "make changes them as and whenever it needs to" variables would
 simply be expanded whenever referenced on any variable assignment, not
 just the := kind (they, and everything else, already are expanded on
 reference in all other contexts I can think of).
 
 As for a syntax, another possibility would be a new variable modifier
 (like there are already hundreds, what's one more!)
 
 I don't see :^ defined as a modifier, so perhaps something like
 
 	${var:^}
 
 could mean "expand var right now" - any other modifiers that follow
 (for simplicity, ^ would need to come first - I don't think there is
 any meaningful conflict with any of the other "must come first" - and
 any others could just come after this "modifier" which doesn't modify
 anything except the time of expansion - and only then when used in
 (other than :=) variable assignment statements - everywhere else it
 would just be a no-op.
 
 So far, I have at least seen no opposition to the general idea of
 adding such a mechanism however.   That's good.
 
 kre
 



Home | Main Index | Thread Index | Old Index