effekt-lang / effekt-lang/effekt

Support for prefix operators

Open
#507 5 comments 0 reactions 0 assignees View on GitHub
area:compiler area:stdlib requires-design
Dominant language
Scala
Stars
469
Forks
41
Avg merge
1d 16h
Merged PRs (30d)
23

Description

Currently, there is neither support for prefix operations like arithmetic negation, that is, `-1` works but `-(1+2)` does not, nor for boolean negation like `!true`. Perhaps this is something we would like to add in the future.

What is your opinion on this?

## Changes

Among others, the following would need to change

1. The lexer no longer lexes negatives numbers but only unsigned numbers.
2. In return, the parser is now responsible for figuring out the precedence of arithmetic negation and see to it that `1 - --2` is (intuitively speaking) parsed as `Sub(1, Neg(Neg(2)))`
3. In [effekt.effekt](https://github.com/effekt-lang/effekt/blob/a4d5f589f1a59a8091f03410f75df735ae77cecc/libraries/common/effekt.effekt#L298-L300), `prefixNeg` and `prefixNot` would need to be added.

(See [feature/prefix-operations](https://github.com/effekt-lang/effekt/tree/feature/prefix-operations) branch)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.