tmikov / scheme2020

An implementation of Scheme R7RS-small in 48 working hours.
MIT License
19 stars 3 forks source link

Compliance of numeric tower #1

Open FrankHB opened 2 years ago

FrankHB commented 2 years ago

The behavior on overlow is not specified. This allows compliant Scheme implementations to exist with de-facto C number semantics.

This seems problematic. C is allowed to crash on overflow. Is Scheme permissive to unexpected behavior and termination of the program in that case?

tmikov commented 2 years ago

Hi, thanks for commenting! I am not an expert in the Scheme specification, so I am not entirely sure whether crashing on overflow is technically allowed in R7RS-Small. But please note that no C implementation commonly available today actually crashes on overflow, so it is a moot point. My plans were to have the Java semantics, which are better defined, and crash only on integer division by zero.

One important difference compared to C signed integer overflow, which C considers "undefined behavior". I would try to avoid that at any cost.

Sadly, I "temporarily" 🤣 stopped working on this project in 2020, and even though I still intend to resume it, I am not sure exactly when.

mnieper commented 1 year ago

R7RS allows a program to crash on numeric overflow.

R6RS prescribes that implementation must raise an exception on overflow.