help-make
[Top][All Lists]
Advanced

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

Re: $x //Re: $(value) of function parameters


From: Markus Mauhart
Subject: Re: $x //Re: $(value) of function parameters
Date: Thu, 10 Jun 2004 00:06:25 +0200

"Paul D. Smith" <address@hidden> wrote ...
>
> [...]
> So the parser works like this: given an input string it looks through it
> until an unescaped "$" is seen.  Then, the parser looks at the next
> char.  If it's at the end of the input string then it's a literal "$".
>
> If it's _NOT_ a "(" or a "{", then this is a single-character variable
> reference and it's expanded as such, then the rest of the string is
> looked at in the same manner.
>
> If it _IS_ a "(" or a "{" then it looks through the string for the
> appropriate closing "}" or ")", doing a count of open/close pairs as it
> goes.
>
> Once it finds the closing "}" or ")"

insert [then any preceding un-escaped "$" is removed and], correct ?

> it expands that string first as a
> function, then (if it's not a function) as a variable.  This may well
> involve invoking this same parsing routine recursively, with that
> substring as the input string.
>
> Then it continues on with the rest of the original string.

IMHO that sounds reasonable. Drawback is only that make380 and make381beta1
additionally show some different unreasonable results (especially "()" and
"{}" are not treated so 'equally' as in your previous explanation):

E.g try out ...

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}]}

... it results in ...

makefile1.txt:16: [value of a] = [az]
makefile1.txt:18: [value of a] = [a)z]
makefile1.txt:20: [value of a] = [az]
makefile1.txt:22: [value of a] = [a)z]

IMHO 2 of the 4 lines show bugs, either 16&20 or 18&22; correct ?
And ...

F = 1=[$1], 2=[$2], 3=[$3], 4=[$4]
$(warning [value of F]= [$(value F)])

a = $(call F,a,$},c)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = $(call F,a,$),c)
$(warning [value of a] = [$(value a)] , [$$a] = [$a])
a = ${call F,a,$},c}
${warning [value of a] = [${value a}] , [$$a] = [$a]}
a = ${call F,a,$),c}
${warning [value of a] = [${value a}] , [$$a] = [$a]}

... results in ...

makefile1.txt:28: [value of F]= [1=[$1], 2=[$2], 3=[$3], 4=[$4]]
[...]
makefile1.txt:37: [value of a] = [$(call F,a,$},c)] , [$a] = [1=[a], 2=[], 
3=[c], 4=[]]
makefile1.txt:39: [value of a] = [$(call F,a,$),c)] , [$a] = [1=[a], 2=[], 
3=[], 4=[],c)]
makefile1.txt:41: [value of a] = [${call F,a,$},c}] , [$a] = [1=[a], 2=[], 
3=[], 4=[],c}]
makefile1.txt:43: [value of a] = [${call F,a,$),c}] , [$a] = [1=[a], 2=[)], 
3=[c], 4=[]]

IMHO either line 37 or (more likely) line 43 shows a bug; correct ?

and ...

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]}

... results in ...

makefile1.txt:50: [value of a] = [$(iftrue,true,false)] , [$a] = [value of var 
with strange name]
makefile1.txt:52: [value of a] = [$(if  true,true,false)] , [$a] = [true]
makefile1.txt:54: [value of a] = [$(if$ true,true,false)] , [$a] = [value of 
var with strange name]
makefile1.txt:56: [value of a] = [$(if$,true,true,false)] , [$a] = [value of 
var with strange name]
makefile1.txt:58: [value of a] = [$(if$}true,true,false)] , [$a] = [value of 
var with strange name]
makefile1.txt:60: [value of a] = [$(if$)true,true,false)] , [$a] = 
[true,true,false)]
makefile1.txt:62: [value of a] = [${if$}true,true,false}] , [$a] = 
[true,true,false}]
makefile1.txt:64: [value of a] = [${if$)true,true,false}] , [$a] = []

IMHO line 58 or (more likely) line 64 shows a bug; correct ?


>   mm> 1) dont change the implementation, but add to the docu:
>   mm>   The effect of using $x with x in ",)}" is deliberately not
>   mm>   documented in this manual, it is deprecated and hence may
>   mm>   be an error in future versions.
>
> No.  It is well-defined, as above.  It will never be an error to use $x;
> that usage is mandated by the POSIX standard and is used by thousands of
> makefiles.

Until now I had overseen POSIX compatibility, allthough it's mentioned more
than once in the manual:
  "GNU make conforms to section 6.2 of IEEE Standard 1003.2-1992 (POSIX.2)"
webstore.ansi.org sells two "1003.2-1992" papers for each ~100$.
www.unix-systems.org has susv2 = UNIX98 specs for download, this AFAICS
claims POSIX.2 compatibility for its make utility. Its susv2/xcu/make.html
is rather short compared with GNUmake's manual.
In case you have access to both: is susv2/xcu/make.html a good approximation
of "section 6.2 of IEEE Standard 1003.2-1992 (POSIX.2)" ?
On 1st view I'd say that UNIX98' make, during expansion of $(String), never
expects any "$" inside String; also GNUmake's manual saying that "computed
variable references" are its own invention is a hint in that direction.
So I hope you understand that I doubt a bit that POSIX.2-make's treatment
of "$)" and "$}" and "$," has much to do with GNUmake's theory and practice.


> Well, you could always examine the code to see how the parser actually
> works! :).  In fact, if your project is released under the GPL you could
> just rip out the parsing function from GNU make and plop it into your
> program... maybe with some vascular surgery around the edges.

I'll look into it, but I still guess that reusing its corresponding
specs & docs is easier than reusing its source.


> The User's Manual is not meant to be a
> technical reference document describing every minute detail of the
> implementation of GNU make--it's a user's manual.
>
> The beauty of open source is you don't need minute technical reference
> documentation--you have the source!

OTOH the manual is really good and detailed in many aspects of variables
and functions, it comes with a nice license too AFAIK, so I thought
implement some parts of it, but reuse the existing specs & docs ...
writing good specs and docs is not really fun nor easy ;-)


Regards,
Markus.







reply via email to

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