[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
$x //Re: $(value) of function parameters
From: |
Markus Mauhart |
Subject: |
$x //Re: $(value) of function parameters |
Date: |
Wed, 9 Jun 2004 00:37:53 +0200 |
"Paul D. Smith" <address@hidden> wrote ...
> %% Noel Yap <address@hidden> writes:
> ny> $(warning $(call fn,$))
[...]
> ny> GNUmakefile:5:
>
> The problem is that the arguments to $(call ...) are themselves
> evaluated before being passed to the function. So, your '$' is being
> expanded before fn gets it.
But why is the 2nd '$' expanded allone instead of expanding '$)' together ?
(Expanding '$)' together IMHO would have to result in the error
"missing closing ')'")
And now, after doing lots of experiments with cygwin's make 3.80-1 and
reading make 3.80 docu, I've got real troubles (cause I want to add
make-compatible variables and functions to upp.sourceforge.net):
6.1 Basics of Variable References:
A dollar sign followed by a character other than a dollar sign,
open-parenthesis or open-brace treats that single character as
the variable name. Thus, you could reference the variable x
with `$x'. However, this practice is strongly discouraged, except
in the case of the automatic variables (see section
Automatic Variables).
Or have I missed other parts of the manual w.r.t. $x-expansion ?
If not, the trouble is that AFAICS make380 doesnt implement this
behaviour w.r.t. the 1st 3 characters in string ",)}"; AFAICS
they behave different from normal (and automatic) single-char-
-variable-names, but also different from each other:
* e.g. the upper (original) example ... according to 6.1, I would
expect "error: missing closing ')'" or similar.
* try out this sample makefile:
#\/\/\/\/\/\/\/\
RP := )
RB := }
$(warning $(empty))
$(warning part1 ... where $(RP) and $(RB) DONT behave analogous:)
$(warning $(empty))
a := a$xz
$(warning [value of a] = [$(value a)])
a := a$$z
$(warning [value of a] = [$(value a)])
a := a$ z
$(warning [value of a] = [$(value a)])
a := a$,z
$(warning [value of a] = [$(value a)])
a := a$}z
$(warning [value of a] = [$(value a)])
a := a$)z
$(warning [value of a] = [$(value a)])
a := a$}z
${warning [value of a] = [${value a}]}
a := a$)z
${warning [value of a] = [${value a}]}
$(warning $(empty))
$(warning part2 ... where $(RP) and $(RB) DONT behave analogous:)
$(warning $(empty))
F = 1=[$1], 2=[$2], 3=[$3], 4=[$4]
$(warning value(F)= [$(value F)])
qwe := $(call F, , , , )
a = $(call F,a,bb,c)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
qwe := $(call F, , , , )
a = $(call F,a,$$,c)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
qwe := $(call F, , , , )
a = $(call F,a,$,,c)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
qwe := $(call F, , , , )
a = $(call F,a,$},c)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
qwe := $(call F, , , , )
a = $(call F,a,$),c)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
qwe := $(call F, , , , )
a = ${call F,a,$},c}
${warning [value of a] = [${value a}] , [$$a] = [$a]}
qwe := $(call F, , , , )
a = ${call F,a,$),c}
${warning [value of a] = [${value a}] , [$$a] = [$a]}
$(warning $(empty))
$(warning part3 ... where $(RP) and $(RB) DONT behave analogous:)
$(warning $(empty))
iftrue,true,false := value of var with strange name
a = $(iftrue,true,false)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = $(if true,true,false)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = $(if$ true,true,false)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = $(if$,true,true,false)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = $(if$}true,true,false)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = $(if$)true,true,false)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = ${if$}true,true,false}
${warning [value of a] = [${value a}] , [$$a] = [$a]}
a = ${if$)true,true,false}
${warning [value of a] = [${value a}] , [$$a] = [$a]}
.PHONY: all
all:
#\/\/\/\/\/\/\/\
Assuming that patched gnumake80 or gnumake381beta still has this
inconsistencies w.r.t. ",)}" I see multiple different solutions
for the next version of gnumake+docu:
1) dont change the implementation, but add to the docu:
The effect of using $x with x in ",)}" is deliberately not
documented in this manual, it is deprecated and hence may
be an error in future versions.
2) dont change the implementation, but change the docu: document
the current behaviour, and probably add something like ...
Using $x with x in ",)}" is deprecated and hence may be an error
in future versions.
3) change the implementation according to the following simple
additional docu:
$x with x in "$,)}" is expanded as if x was a simply expanded
variable, with value of x = name of x = x; e.g. after line
"A := x" (and A never changed elsewhere), $A and $x are completely
interchangable.
4) change the implementation according to the following simple
additional docu:
$x with x in ",)}" is expanded as if x was a simply expanded
variable with empty value; e.g. after line "A :=" (and A never
changed elsewhere), $A and $x are completely interchangable.
And dont forget x in ":=" or other ASCII-non-isalnums currently
not representing automatic variables ... maybe for all of them
$x should be 'reserved/deprecated' -> 1) or 2).
Any other suggestions that might help me parsing and implementing
make-compatible variables and functions ?
Regards,
Markus.