[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A little m4 puzzle
From: |
Doug McIlroy |
Subject: |
A little m4 puzzle |
Date: |
Sat, 10 Nov 2018 13:01:40 -0500 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Consider this predicate on strings.
define(eq,`define(`_$1',F)define(`_2',T)_$1')
eq(x,y) yields T or F according as strings x and y are
the same or different. (The strings may contain only
characters allowed in macro names).
The puzzle: If you omit inner quotes from the definition,
eq(A,A) yields T as intended. But what happens when you
repeat the test?
(Incidentally, you can replace T by `$3' and F by `$4'
to make a near replacement for the builtin ifelse.)
- A little m4 puzzle,
Doug McIlroy <=