[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] on \$0
From: |
Bernd Warken |
Subject: |
Re: [Groff] on \$0 |
Date: |
Fri, 12 Jul 2002 12:47:03 +0200 |
User-agent: |
Mutt/1.2.5i |
On Fri, Jul 12, 2002 at 10:05:40AM +0200, Werner LEMBERG wrote:
>
> Have a look into trace.tmac. For example, you could do the following:
>
> .rn de de!!
> .de!! de
> . ds namespace \\$1
> . de!! \\$1
> ..
> .
> .de test
> . ds \\*[namespace]:s xxx
> ..
> .
> .als M test
> .M
> .
> .tm \*[namespace]:s
> => test:s
> .tm \*[\*[namespace]:s]
> => xxx
>
> IMHO this should be sufficient for your purposes.
>
This works if you do not call your macros within other macros.
The following example does not work:
.rn de de!!
.de!! de
. ds namespace \\$1
. de!! \\$1
..
.
.de child
. ds \\*[namespace]:s yyy
. tm c: \\*[namespace]:s
. tm c: \\*[\\*[namespace]:s]
..
.de parent
. ds \\*[namespace]:s xxx
. child
. tm p: \\*[namespace]:s
. tm p: \\*[\\*[namespace]:s]
..
.parent
.ex
=>c: parent:s
=>c: yyy
=>p: parent:s
=>p: yyy
BTW, if you run this with `groff -m trace' you will an unjustified
error message
*** de trace enter: de "child"
0.t:7: fatal error: input stack limit exceeded (probable infinite loop)
########################################################################
Another reason is of aesthetical nature. I want to avoid ugly
structures like `\\*[namespace]:s' or `groff:package:container:macro:s'.
Using `\$0:s' is tolerable, while longer expressions make programming a
torture and tend to hide errors.
So if there is a method to enable \$0 this would be a giant step
towards safe local name spaces. The problems from overriding local
names in subsequent macro calls leads to serious bugs that are often
hard to be detected. I wasted a lot of time on tracking such
unnecessary bugs.
Bernd Warken