Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <uvcqn3$2pju0$1@dont-email.me>
Deutsch   English   Français   Italiano  
<uvcqn3$2pju0$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.lang.misc
Subject: String-Based Macro Systems
Date: Sat, 13 Apr 2024 02:29:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <uvcqn3$2pju0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 13 Apr 2024 04:29:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c07c9bb19a0975fd36cf4a2cbd5e0704";
	logging-data="2936768"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/2fvop800Pf1Djeqvf9uy3"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:sVkClwXkjr7eI1Y7CzC+FKk2tFg=
Bytes: 3470

I think most of us are familiar with the “#define” preprocessor in C and 
C++. There are more powerful macro processors around, like GNU m4. They 
all have the same basic concept: pass input text straight through to 
output, until something triggers a macro substitution on the text.

The original m4 was created by the Unix folks at Bell Labs, modelled on an 
earlier concept called “Macrogenerator” by Christopher Strachey (one of 
the brains behind the programming language CPL, which led to BCPL, which 
led to B and then C). Macrogenerator had special symbols to indicate macro 
definition, and macro and argument expansion:

    §DEF,«name»,<«definition»>;

where the “<” and “>” are actual quote symbols in the notation, while I 
use “«” and ”»” as metasyntactic brackets. Within the «definition», 
occurrences of “~1”, “~2” etc are replaced with the first, second etc 
actual argument specified in the call. You then use this macro as

    §«name»,«args»;

where multiple arguments are comma-separated.

Simple example: given

    §DEF,greetings,<Hello, ~1!>;

then

    I would just like to say, “§greetings,world;” to anybody listening

should expand to

    I would just like to say, “Hello, world!” to anybody listening

Here is a moderately interesting example, from the Bryan Higman book where 
I first heard about this. It uses a builtin called §UPDATE, which does 
assignment to an existing macro name, and also note the occurrence of 
§DEFs within §DEFs, for local (temporary) macro definitions (since the 
auxiliary macro §Q has to persist between invocations, it cannot be one of 
these):

    §DEF,Q,A;
    §DEF,AORB,<§§Q;;>,§DEF,A,<A§UPDATE,Q,B;>;,§DEF,B,<B§UPDATE,Q,A;>;;

What this does is, each time you write “§AORB;”, it expands to alternately 
“A” or “B”.

The big difference with m4 is that it does away with these special 
symbols; the mere occurrence of a name matching a defined macro (or an 
argument of the macro currently being expanded) is sufficient to trigger 
substitution. Do you think this is a good idea?

There are all kinds of pitfalls with such macro systems. The original 
Macrogenerator could not cope with substitutions containing unpaired 
“< ... >” quote symbols, and even GNU m4 lacks something as simple as a 
backslash-style “escape next single character, whatever it is”. While m4 
lets you switch the quoting symbols, it still insists that they occur in 
pairs.

Would adding such an escape character be useful?