effekt-lang / effekt-lang/effekt

Inconsistent modulo / remainder behaviour

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

Description

Different backends act differently given the following file:
```scala
def main() = {
println(7.mod(3)) // 7 % 3
println(7.mod(neg(3))) // 7 % -3
println(neg(7).mod(3)) // -7 % 3
println(neg(7).mod(neg(3))) // -7 % -3
}
```

JS, LLVM:
```
1
1
-1
-1
```

but on Chez:
```
1
-2
2
-1
```

because Chez actually does `(modulo x y)`, but other backends do `(remainder x y)`.

I think the proper solution here would be to make Chez consistent with other backends (`s/modulo/remainder` in the code), then rename `mod` to `rem`, and add an _actual_ `mod`ulo to complement it, much like Haskell does.

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.