[SUBDIRMK RFC 6/7] README: v2: Draft - macro assistance facility
Ian Jackson
ijackson at chiark.greenend.org.uk
Wed Dec 11 16:37:13 GMT 2019
Not implemented yet. Also no S-o-b at this time!
Very much RFC.
In particular I wonder if the author of a &:macro will ever want a way
to write (say) "$(dirname $3)". If all $ not in front of digits are
doubled in &:macro, this is impossible. Maybe we need a literal $.
"&$@" ? "&\$" ? "&$$" ? Should we provide "&\&" rather than &@ ?
Maybe "&$(" should be special ? "&$(dirname $3)" seems quite nice
compared to "&\$(dirname $3)" or something. Even if we do that
logically we still need provide something that expands to just the $.
Do we need something to turn on and off $-doubling ? &$ SPC or &$$ or
something maybe. The &:macro commit proposes two kinds of $-doubling
which means we would need multiple ways to turn it on and off. (I'm a
bit uncomfortable with burying this $-doubling feature in a cooked
thing like &:macro.)
Maybe macro arguments are &1..&9 which expand to $1..$9, which avoids
the need for two subtly different $-doubling modes.
---
README | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/README b/README
index e87cb80..6dd1a05 100644
--- a/README
+++ b/README
@@ -322,6 +322,32 @@ So pathname syntax is a subset of:
`all' is extra special: every directory has an `all'
target, which corresponds to &TARGETS.
+DRAFT - MACRO ASSISTANCE FACILITY
+---------------------------------
+
+Thanks to Mark Wooding.
+
+ &:macro NAME
+ STUFF
+ &:endm
+
+expands to
+
+ define %NAME
+ STUFF (with `$'s doubled except before a digit)
+ endef
+ NAME = $(eval $(call %NAME,$1,$2,$3,$4,$5,$6,$7,$8,$9))
+
+and
+
+ &(NAME ARG,ARG,...)
+
+expands to
+
+ $(call NAME,ARG,ARG,...)
+
+with `$'s doubled.
+
Subdirectory and variable naming
--------------------------------
--
2.11.0
More information about the sgo-software-discuss
mailing list