udem-dlteam / ribbit

A small and portable Scheme implementation with AOT and incremental compilers that fits in 4K. It supports closures, tail calls, first-class continuations and a REPL.
BSD 3-Clause "New" or "Revised" License
479 stars 42 forks source link

Is Proper Ratio Support on the Roadmap? #67

Open BSlug opened 3 months ago

BSlug commented 3 months ago

Currently, I believe e.g. (/ 9 2) evaluates to 4. I’ve read that float support is unlikely to happen for portability reasons, but ratios could offer a middleground.

l4haie commented 3 months ago

We’re actively working towards supporting floats in ribbit, hopefully this will be done by the end of summer!

BSlug commented 3 months ago

Will there be a way to easily exclude floats from the numerical stack, for systems such as microcontrollers where the float routines would increase the binary size considerably?

leo-ard commented 3 months ago

yes ! This will be done through the feature system of ribbit. To have proper floats, you will need to enable the "float" feature.

It will use the underlying implementation when available. For example, if running on the C RVM, the already existing implementation of floats can be reused. Only conversions between Scheme and C need to be handled.

For hosts that don't have native support for floats, I'm not yet sure what we are going to do as emulating them would be quite a challenge and would probably result in pretty slow implementation of IEEE-754 floats. Maybe a scheme library that support ratios could be a good middle-ground