Programming Language for Old Timers


by David A. Moon
February 2006 .. September 2008

Comments and criticisms to dave underscore moon atsign alum dot mit dot edu.


Previous page   Table of Contents   Next page


String Template Syntax

Question mark can be a special character in a string literal in data syntax, i.e. following a #. Question mark is special when followed by a left parenthesis or a character that can be the start of a name, i.e. one of

   ( letters digits ~ ! @ $ % ^ & * _ - + = | : < > /

In this case the apparent string literal is actually a template that constructs a string. Each special question mark is followed by a name and the value of that name is substituted into the constructed string. The name is either delimited by a non-name character or is enclosed in parentheses.

A question mark preceded by backslash or followed by whitespace, punctuation (other than open parenthesis), semicolon, single or double quote, or the end of the string is just an ordinary character.

When a string template is used, it macroexpands into an invocation of the string function with one argument for each segment of string and one argument for each value to be inserted. The string function converts all its arguments to strings and concatenates them into one string.


Previous page   Table of Contents   Next page