groff
[Top][All Lists]
Advanced

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

[Groff] pic syntax blemishes


From: Doug McIlroy
Subject: [Groff] pic syntax blemishes
Date: Wed, 26 Apr 2017 17:36:56 -0400
User-agent: Heirloom mailx 12.5 7/5/10

This pic fragment
        d = 3
        circle radius 2d
draws a circle of radius 2, not 6 as one might suppose. It is parsed as
        circle radius 2 d
and the "irrelevant attribute" d is ignored.

In another context
        d = 3
        move 2d
the parsing results in a move of 2 then of d. Thus 2d is sometimes
taken as 2 and sometimes as 2+d, but never as 2*d.

Yet another confusion arises here:
        nd = 3
        move 2 nd
        move 2nd
The first move behaves like move 2+nd, but the second (pun not intended)
is an error, because the pic tokenizer recognizes 2nd (also 2st and 2th)
as an ordinal.

The treatment of irrelevant attributes also allows crazy code like
        box radius 3

The convention of dropping irrelevant attributes may have been justified
during the experimental days of pic's development, but seems cheesy now,
nearly 40 years on.

The fact that 2d gets tokenized differently from 2nd is also disconcerting.

I suggest that irrelevant attributes and constructions like 2d should
be errors. Any previously working code that such a tightening of syntax
might reject will be easy to fix.

What do folks think about this issue? Depending on response, I may try to
do something about it.

Doug



reply via email to

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