groff
[Top][All Lists]
Advanced

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

Re: [Groff] pic syntax blemishes


From: Brian Kernighan
Subject: Re: [Groff] pic syntax blemishes
Date: Wed, 26 Apr 2017 18:47:07 -0400 (EDT)
User-agent: Alpine 2.20 (LRH 67 2015-01-07)

The number of (g)pic users in the world must be pretty small
by this point, though I am among them, thanks to gpic et al.

Oddly the sequence
        d = 3
        r = 2d
does draw an error message from gpic.

On Wed, 26 Apr 2017, Doug McIlroy wrote:

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]