Skip to content

math: Make function parentheses optional#7877

Merged
faho merged 5 commits into
fish-shell:masterfrom
faho:math-optional-parens
Mar 30, 2021
Merged

math: Make function parentheses optional#7877
faho merged 5 commits into
fish-shell:masterfrom
faho:math-optional-parens

Conversation

@faho
Copy link
Copy Markdown
Member

@faho faho commented Mar 29, 2021

It's a bit annoying to use parentheses here because that requires
quoting or escaping.

This allows the parens to be omitted, so

math sin pi

is the same as

math 'sin(pi)'

Function calls have the lowest precedence, so

math sin 2 + 6

is the same as

math 'sin(2 + 6)'

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

It's a bit annoying to use parentheses here because that requires
quoting or escaping.

This allows the parens to be omitted, so

math sin pi

is the same as

math 'sin(pi)'

Function calls have the lowest precedence, so

math sin 2 + 6

is the same as

math 'sin(2 + 6)'
@faho faho added this to the fish 3.3.0 milestone Mar 29, 2021
@ridiculousfish
Copy link
Copy Markdown
Member

Nice! This would benefit with tests for nested calls and mixed arities, e.g. math 'sin cos 3' and math 'pow sin 3 5'

@faho faho force-pushed the math-optional-parens branch from 4103cbb to cbaaa6c Compare March 29, 2021 21:00
Call me Nikola Testla
@faho faho merged commit ed9268f into fish-shell:master Mar 30, 2021
@faho faho deleted the math-optional-parens branch March 30, 2021 15:21
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants