[Top][All Lists]

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

[bug #43432] Two flavors of variable: describe more aptly, in line with

From: Kaz Kylheku
Subject: [bug #43432] Two flavors of variable: describe more aptly, in line with other languages.
Date: Fri, 17 Oct 2014 18:50:59 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0


                 Summary: Two flavors of variable: describe more aptly, in
line with other languages.
                 Project: make
            Submitted by: kkylheku
            Submitted on: Fri 17 Oct 2014 11:50:57 AM PDT
                Severity: 3 - Normal
              Item Group: Documentation
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: None
        Operating System: None
           Fixed Release: None
           Triage Status: None



The GNU Make manual describes "two flavors of variable", at length. The
"flavors" are called "recursively expanded" and "simply expanded".

In fact, the situation is that the := and ::= variables are more or less what
people understand as variables in programming languages like the POSIX shell,
Lisp or C.  When the name of such a variable appears somewhere (perhaps with
some special sygil syntax like $FOO, $(FOO) or ${FOO} or whatever), it behaves
as an expression which is reduced to the value of the variable: what it

The traditional make variables pretty much correspond to unparametrized
macros: they are like preprocessor macros in the C language, or
define-symbol-macro macros in Common Lisp.  When an expression is evaluated
which names a macro, that macro is understood to contain syntax which is
substituted into that expression. That syntax is then evaluated in its place,
which means that it is scanned for occurrences of more macros. This seems to
be more or less exactly what happens with the classic make variables defined
with the simple equal sign.

So the two flavors are simply "variable" versus "macro", and the = operator is
not a variable assignment but in fact a macro definition like #define. The
right hand side is not evaluated, but its syntax is stored into the left hand
side symbol verbatim. When the symbol is later referenced, then that material
is expanded: looks like a macro, walks like a macro, quacks like a macro, ...

When its left operand is a macro, the += operator behaves as a "macro append"
(appending to a macro is found in some languages, like for instance in the
troff typesetting language).

When its left operand is a variable, the += operator behaves as an append to a

Speaking of troff, it has parallel features: in troff you can define a string
(.ds) and append to a string (.as). You can also define a macro (.de) and
append to a macro (.am). Macros resemble strings, except that invoking a macro
recursively expands (and can have arguments), whereas a string is just
substituted verbatim and that is that. It is very similar to the two "flavors
of variable" in GNU Make.

Troff also has something similar to $(call): a way of interpolating arguments
into a variable, namely the \*[name arg1 arg2 ...] syntax where name is a
string. This doesn't mean that "name" is a macro, just that this way of
referencing it treats it as one.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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