# [Latte] words and variables

Bart Schaefer schaefer@zanshin.com
Thu, 22 Mar 2001 14:06:38 -0800 (PST)

On Tue, 20 Mar 2001, Daniel Mahler wrote:

> The problem is that I want the name of the refernce, without the "\"
> to appear in the output of the template

Ah.  There's no way to do that purely within latte; variables are
variables and strings are strings and you can't do symbolic conversions
from one to the other.

However, you can do something like this:

{\def \template
{\macro {\fn}
{\{\process-output echo
{\concat
\""{\\def {\\\"
\,\fn
\" \\one \\two} {\\two \\one}}" > \"
\,\fn
\".latte\"}}
\{\load-file \,\fn\/.latte}}}}

Which, invoked as

{\template swap}

writes the file swap.latte containing the definition of the \swap
function, and then loads that file.  You could extend this to only write
the file if it doesn't already exist, etc.

You might consider looking at the C++ source for the \load-file builtin,
because it shouldn't be very difficult to invent \compile-string based on
it, which would avoid the need to write and read a file.