Changed HeapLang operator macros to support both parentheses and spaces
The current macro definitions in heaplang.sty
favour a syntax style in which function applications use parenthesised arguments, e.g. fn(arg)
.
Following a discussion on the Iris helpdesk board, it can be argued that both the styles fn(arg)
and fn arg
have individual merits,
and that authors may wish to use either when e.g. defining their BNF syntax.
It thus makes sense to update the macros so that they support both (if possible).
An attempt at achieving this is contained in this MR.
The idea is that the macros will insert a space
, when the given argument is not parenthesised.
For use cases with uncurried arguments such as Alloc e1 e2
the user should write \Alloc\expr_1\spac\expr_2
.
There are multiple ways of achieving this.
- Adopting the
\operatorname
latex style, which achieves exactly what we want (proposed by @neven) - Using
ifthenelse
along withxstring
to check if the first character of the argument is(
The MR uses solution 1.
EDIT:
Changed \mathop
to \operatorname
as it does not cause aforementioned unwanted subscript behaviour.
Changed \DeclareMathOperator
to \operatorname
for consistency, as they unfold to the same thing (according to https://tex.stackexchange.com/questions/84302/what-is-the-difference-of-mathop-operatorname-and-declaremathoperator).
Reverted \Ref
-> \NewRef
change, as it is no longer enforced by \DeclareMathOperator
(this should still be done in a separate MR though).