groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comprehension problem with macros


From: Oliver Corff
Subject: Re: Comprehension problem with macros
Date: Sun, 23 Apr 2023 14:32:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0

Hi Ralph,

yes, I remember having heard of the two different modes but had only a
passive understanding.

Thank you for pointing this out!

I also see that you avoid going through .ie n < 10 then n .el \*[n]
construction. I was not quite sure if I could abuse single-digit numbers
in such a way.

Best regards,

Oliver.


On 23/04/2023 14:24, Ralph Corderoy wrote:
Hi Oliver,

.nr number 0 1
.while (\n[number] < 16) \{\
.ie (\n[number] < 10) \[u4E0\n[number]]
.el \[u4E0\*[\n[number]]]
.nr number +1
.\}

So far, everything works perfectly.

However, if I wrap this loop in a macro like

.de myline
.\" material as above
..
The text after .de is read twice.  Once when the macro is defined and
again when it is executed.  The reading occurs in two different modes.
See section 7 of CSTR 54.  https://troff.org/54.pdf

For example, \nn puts the value of number-register n when the macro is
defined into the macro whereas \\nn delays getting the value of n to
when the macro is executed.

Here's a variation on your test.

     $ cat oliver.tr
     .pl 2
     .
     .ds 0 0
     .ds 1 1
     .ds 2 2
     .ds 3 3
     .ds 4 4
     .ds 5 5
     .ds 6 6
     .ds 7 7
     .ds 8 8
     .ds 9 9
     .ds 10 A
     .ds 11 B
     .ds 12 C
     .ds 13 D
     .ds 14 E
     .ds 15 F
     .
     .nr n 0 1
     .while (\n[n] < 16) \{\
     \[u216\*[\nn]]
     .nr n +1
     .\}
     .br
     .
     .de m
     .nr n 0 1
     .while (\\n[n] < 16) \\{\\
     \\[u216\\*[\\nn]]
     .nr n +1
     .\\}
     ..
     .m
     $ troff -Tutf8 oliver.tr | grotty
     Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ Ⅼ Ⅽ Ⅾ Ⅿ
     Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ Ⅼ Ⅽ Ⅾ Ⅿ
     $

--
Dr. Oliver Corff
Wittelsbacherstr. 5A
10707 Berlin
G E R M A N Y
Tel.: +49-30-85727260
Mail: oliver.corff@email.de




reply via email to

[Prev in Thread] Current Thread [Next in Thread]