[Top][All Lists]

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

Re: [Groff] condition: OR of two string comparisons

From: Steffen Nurpmeso
Subject: Re: [Groff] condition: OR of two string comparisons
Date: Wed, 26 Nov 2014 19:08:31 +0100
User-agent: s-nail v14.7.8-73-g5bf9347

Tadziu Hoffmann <address@hidden> wrote:

 lots of interesting stuff skipped

 |As an aside at the end, I'm surprised that no-one has yet
 |pointed out the obvious:  we're working with a macro
 |processor, where the natural block structuring element
 |is not a tacked-on brace structure, but the *macro*!

 |And another example, since something similar had come up:
 |  .de inlist?
 |  .ie \\n(.$<2 .nr result 0
 |  .el .inlist1 \\$@
 |  ..
 |  .de inlist1
 |  .ie '\\$1'\\$2' .nr result 1
 |  .el .inlist2 \\$@
 |  ..
 |  .de inlist2
 |  .ds _1 \\$1
 |  .shift 2
 |  .inlist? \\*(_1 \\$@
 |  ..
 |  .ds fruit apple banana lemon grape
 |  .ds myfruit lemon
 |  .inlist? \*[myfruit] \*[fruit]
 |  .ie \n[result] Yes, ``\*[myfruit]'' is in ``\*[fruit]''.
 |  .el             No, ``\*[myfruit]'' is not in ``\*[fruit]''.
 |Programming roff is a bit like programming in assembler:
 |complex expressions are built up piece by piece using simple
 |instructions, and temporary registers are a useful aid, not
 |something that must be avoided at all costs.

Nice. But it won't match ".ds myfruit \&lemon", to give one
example.  I know of no way to get at the plain "lemon" in
"\&lemon", which is a complete stopper for any generic
programming, whatever conditional or recursive functional approach
there is used.  Not being able to return a value is a thing that
i also miss a lot.  Having a last-macro-return-value register
would be nice in my opinion.  Unfortunately ".return anything" yet
exists and has special semantics, so a ".retval VALUE" or the like
would be necessary.  Variables with macro-local (namespace) scope
would also be a real improvement: since you've mentioned the
shell, ".local [ds|nr] xy" comes to mind.
In the end the best would be if any user can use the syntax he
(or she -- really?) likes the most, and it should just work.
So this makes .tostring, .returnval and .local.


reply via email to

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