Demand: "Better" syntax for demand signatures
@simonpj said that he doesn't quite like the current syntax (since #18903 (closed), see also the updated entry for -fstrictness in the user's guide on master) of demand signatures, in particular the abbreviations of Cards and the fact that we now prefix product demands with P (e.g. SP(SU,A)).
Abbreviation for Cards
The current abbreviations for Cards are
| interval | set of denoted cardinalities | ppr syntax | explanation tying syntax to semantics |
|---|---|---|---|
| [1,0] | {} | B |
bottom |
| [0,0] | {0} | A |
absent |
| [0,1] | {0,1} | 1 |
used at most once |
| [0,n] | {0,1,n} | U |
top, no information, used at least 0 and at most n times |
| [1,1] | {1} | S |
strict, used exactly once |
| [1,n] | {1,n} | M |
"multi-strict", used at least once, but possibly many times |
Simon argued that
- he always mistakes
1to mean "exactly once" rather than "at most once" (The only reason I chose 1 here in the first place was that usage demands prior to #18903 (closed) used it that way) - then thinks that
Sis a better fit forM -
Ushould really beLazy. (similarly, I choseUbecause it was the top element in the usage lattice, no particular reason.)
His suggestions leave open how to name "at most once" then. He proposed F for "few", but I'm not satisfied with that.
So, in summary, we have
| interval | set of denoted cardinalities | ppr syntax | explanation tying syntax to semantics |
|---|---|---|---|
| [1,0] | {} | B |
bottom |
| [0,0] | {0} | A |
absent |
| [0,1] | {0,1} | M |
used at most once, "Maybe" |
| [0,n] | {0,1,n} | L |
top, no information, used at least 0 ("lazy") and at most n times |
| [1,1] | {1} | 1 |
used exactly once |
| [1,n] | {1,n} | S |
used at least once, but possibly many times |
Product sub-demands
Simon proposed to omit the P in a demand like SP(SU,A) --> S(SU,A). But if we omit the P in call sub-demands, in which product sub-demands occur without the leading evaluation cardinality of the surrounding demand, look a bit weird because of the doubly nested parentheses: C1(P(SU,A)) --> C1((SU,A)). We can't omit them, otherwise C1(SU) is ambiguous with C1(P(SU)).
Maybe the doubly nested parentheses are OK.
Summary
We need to settle on a notation for cardinalities, where the "used at most once" slot is contested the most, and also decide whether we want to drop the P in product sub-demands, which means making peace with doubly nested parentheses C1((SU,A)).
The discussion ultimately settled for M ("Maybe") and not omitting the P.