Coder Social home page Coder Social logo

false-schemers / s4iof Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 172 KB

S4IOF (Scheme 4 In One File) is a minimal interpreter for R4RS Scheme

License: BSD 3-Clause "New" or "Revised" License

C 100.00%
scheme scheme-language scheme-interpreter scheme-r4rs minimalist scheme-programming-language

s4iof's Introduction

S4IOF (Scheme 4 In One File) - A Minimal R4RS Scheme System

S4IOF is a portable interpreter for a subset of the Scheme programming language. It can be built from a single portable C source file s4iof.c; there are no OS- or hardware-specific parts, no compiler-specific tricks, no dependency on platform-specific building tools. There is no distributive to install: just compile the file with your favorite C compiler, link it with the standard C runtime libraries and be done with it.

Installation

There is no installation to speak of; just grab the file and compile it with your favorite C compiler.

Here's how you can compile S4IOF on a unix box:

gcc -o s4iof -O3 -DNDEBUG s4iof.c -lm

Please note that some compilers may issue hundreds of warnings; we recommend to add -Wno-parentheses-equality for Clang and -D_CRT_SECURE_NO_WARNINGS for Windows headers (unless you want to hear that fopen is no longer a reasonable way to open files).

If you specify high optimization settings as in the example above, be ready for long compilation times. But it's usually worth the wait: the executable is smaller and faster (which is important because the speed was traded for code size).

The resulting interpreter has no dependencies and can be run from any location.

Scheme Compatibility

S4IOF is true to basic Scheme principles -- it features precise garbage collector, supports proper tail recursion, call/cc, dynamic-wind, and multiple return values. It is mostly compatible with R4RS, but it has the following known limitations and deviations from the standard:

  • hygienic macro facilities (define-syntax & friends) are not implemented
  • there is a simple define-macro facility for S-expression rewriting
  • single-argument eval is available
  • fixnums are limited to 24 bits, flonums are doubles
  • no support for bignums/rational/complex numbers
  • some run-time errors such as zero division and fixnum overflows trigger asserts in C code unless NDEBUG is defined during compilation

S4IOF supports some popular extensions defined in other standards and libraries:

  • error (not based on exceptions)
  • file-exists?, delete-file, rename-file
  • exit, abort, reset, command-line
  • get-environment-variable, system, current-jiffy, jiffies-per-second

Origins

SIOF's original code is written in #F, a language for building Scheme-like systems. Its #F source code can be found there in examples directory:

s4iof.sf

SIOF's on-the-fly compiler is derived from Marc Feeley's Scheme Interpreter (see gambit/bench/src/scheme.scm in the Gambit Scheme repository). Supporting library code comes from #F's LibS library.

Family

Please see S5IOF for a smaller system with hygienic macros, SIOF for the latest (and biggest) single-file scheme implementation.

s4iof's People

Contributors

dermagen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.