Are pragmas always "instructions"? (was: Re: What is a pragma?)

Re-reading this, I think I see something that I would like to understand
better.

Norm Tovey-Walsh writes:

> We offer what follows in the hope that it will kick-start discussion
> to help us move forward before next week’s meeting.

Thank you; it is in that spirit that this response is written.

> # What are pragmas?

> Broadly speaking, pragmas are instructions embedded in source code,
> which extend the structures available in the language of the source
> code.

Describing pragmas as instructions seems to suggest that they will by
nature have an imperative meaning.

Is that suggestion intended?

If it is intended, then that's a point on which I would be inclined to
dissent: some things which I think can plausibly be done with pragmas
have, as far as I can tell, most naturally a declarative interpretation.

For example: pragmas for name changes can be glossed in an imperative
way (change the name from x to y) but I think they make better sense if
phrased declaratively.

If a pragma indicates that a nonterminal describes a regular language
and that it is safe to recognize instances of that nonterminal with a
greedy regular expression match -- well, the description I just gave
does not include anything I recognize as an instruction to a processor.
If we take seriously the description of pragmas as instructions, the
pragma I just described would seem to be a misuse of the mechanism, or
not *really* a pragma.  I would prefer that it be identified as a
legitimate use of pragmas.

Similarly, attribute grammars are, like BNF and ixml, a purely
declarative notation.  They are not, at least in the descriptions I am
most familiar with, instructions, any more than an ixml grammar is.

One way to choose a parse tree is to specify a scoring function to score
parse trees, and choose higher-scoring parse trees in preference to
lower-scoring parse trees.  But statements like "a tree using this
right-hand side scores 10 for this node" and "a tree using this
right-hand side scores 0 for this node" are not instructions as I
understand the term, but declarative statements.

Since pragmas may be defined using declarative semantics, as well as
with imperative semantics, the word "instructions" makes me nervous;
saying that pragmas convey information (and in particular information
not conveyed by the standard semantics of ixml, or not conveyed in the
same way) seems more general, and is intended to cover both declarative
and imperative semantics (and anything else).



-- 
C. M. Sperberg-McQueen
Black Mesa Technologies LLC
http://blackmesatech.com

Received on Saturday, 29 January 2022 02:10:51 UTC