[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Argument evaluation

Parameters in traditional programming languages are evaluated before the call: If the variable a has the value 10, then
 
print a
would print 10.

Shells (and Tcl) put implicit quotes around the arguments,, and you have to use an evaluate operator to undo the quoting. For example the operand xx$(a)yy is implicitly translated into (string_concat "xx" a "yy").

Implicit quoting is convenient when most arguments are constants, as in interactive use. Consider the alternative:
 
mv "-i" "foo.c" "foo.c.old"

One the other, implicit quoting is clumsy when there are other data types in addition to strings. For example in:
 
abs -10
we want to pass the integer -10 to the `abs' routine, not the string "-10".

Q's solution is to provide macros, similar to those in Lisp: A macro is a function that is run at compile time to transform an expression into a different expression. Q provides primitives that makes it convenient to write macros in user-oriented terms. These are discussed next.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Per Bothner on December, 4 2001 using texi2html