groff
[Top][All Lists]
Advanced

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

Re: [groff] A macro package for lists in TROFF


From: Ralph Corderoy
Subject: Re: [groff] A macro package for lists in TROFF
Date: Wed, 06 Dec 2017 22:57:30 +0000

Hello you two,

> Stephanie wrote:
> > However, Troff's ability to take values of a numerical register and
> > use it as a name to another register (.nr my_\na_\nb) intrigues me
> > very much.
>
> I do not know if that "feature" was an intentional design or an
> accident, and I do not know either if it is considered a good practice
> or an abuse to take advantage of it, but I find it very useful.

I don't know if `intentional' is the right word, more likely `obvious'
for the time.  If you've only ever been used to `macros' as seen in C's
cpp(1) then you haven't been exposed to the more powerful macros that
were common to aid the simpler languages of the time, e.g. assembler.

Today, m4(1) is still around from that era, along with troff, and is
worth examining.  https://en.wikipedia.org/wiki/M4_(computer_language)
autoconf and sendmail still use it.  And some years ago now, I
supplemented a BCPL-like language that only offered the machine word.
It was used to add `probes' to executables without recompiling.  Fine
for small things, but it was pushed into more complex tasks and chasing
through structs and pointers with nothing but arithmetic because tedious
for its users so I used m4 to provide `struct'-defining statements that
in turn defined more macros that would do the member accesses and
pointer dereferences given based addresses, all based on the identifiers
used in the executable's source.

Lisp also takes macros to town.  Both code and data are lists in Lisp,
and macros allow manipulating those lists during `parsing'.  A skilled
Lisp zealot writes any non-trivial program in a unique dialect of Lisp,
having cajoled the language with macros to fit the domain.  I don't say
this in praise, just as another data point.  :-)

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy



reply via email to

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