adam-mcdaniel / dune

A shell🐚 by the beach🏖️!
https://adam-mcdaniel.net/dune-website
MIT License
1.01k stars 20 forks source link

Allow operators as symbols in various places #63

Closed Aloso closed 3 years ago

Aloso commented 3 years ago

This allows operators such as + or % in a few places where previously only symbols were allowed:

In all other places, the operator must be wrapped in parentheses:

echo 3 (+) 5  # prints the integer 3, the addition operator and the integer 5
(+)@-         # accesses the key `-` of the object `+`

Operators can still be used in infix position:

> 3 + 5 == (+ 3 5)
True
> fmt @ dark @ blue == (@ fmt dark blue)
True

@, | and >> are turned into operators. They were classified as punctuation before, which doesn't make sense because unlike punctuation they can be overloaded.

! is added, which I apparently forgot to add to the tokenizer.

Builtin operators are renamed to the respective symbol. E.g. __add__ is now +, and redirect-to is now >>.

adam-mcdaniel commented 3 years ago

I much prefer defining operators by their actual symbol names instead of names like __add__, this is great!