tmikov / scheme2020

An implementation of Scheme R7RS-small in 48 working hours.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compliance of numeric tower

FrankHB opened this issue · comments

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?

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.

R7RS allows a program to crash on numeric overflow.

R6RS prescribes that implementation must raise an exception on overflow.