Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Non-redundant parentheses being stripped in parametrized directive #112

@jegi

Description

@jegi

I want an indexed identifier fi for various i, so I make it a parametrized macro. The index is self-delimiting---I don't need parentheses in fi+j---so I define it to strip parentheses from the index:

%format f (x) = f "_{" x "}"

But I also want to format it as a single token, even when it is passed as an argument to something else---I also don't want parentheses in h fi+j---so I also strip off parentheses from the outside:

%format (f (x)) = f "_{" x "}"

This works for the original use case h fi+j:

h (f (i+j))

and is as described in Section 7.5 of Guide2.pdf.

But it does not work as I expect when I apply fi+j to an argument x then apply h to the result:

h (f (i+j) x)

I get h fi+j x, and I think some non-redundant parentheses are being stripped off, namely those around the application of fi+j to x.

To get round this, I have to supply some extra (I think redundant) parentheses---either round the indexed function, to satisfy its hunger:

h ((f (i+j)) x)

or an identical second pair around the whole argument to h:

h ((f (i+j) x))

Sample input (as TXT because Github blocks LHS) and output attached.

brackets.pdf
brackets.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions