GithubHelp home page GithubHelp logo

forthlisp's Introduction

Lisp in Forth

This is an interpreter for a really simple dynamically scoped Scheme dialect. It only runs with Gforth, because it uses Gforth's structs to implement its data structures. One of the more involved parts of this interpreter is the reader, where I had to do quite a lot of stack juggling to keep everything in line. It doesn't look very involved now but I remember spending quite some time thinking about the stack layout for the reader routines. Read here why the way I did it is most certainly wrong.

How to use it

Assuming you have Gforth installed (if you're on MacOS you can get it via Brew), start it with

gforth lisp.fs

There are mainly three words of interest:

  • lisp-load-from-string reads and evaluates a string.

  • lisp-load-from-file reads and evaluates a file, given a filename.

  • lisp-display prints a lisp value.

Example:

s" (+ 1 2 3)" lisp-load-from-string lisp-display
=> 6 ok

s" test.scm" lisp-load-from-file lisp-display
=> 4 120 () ok

In this example, 4 and 120 are printed in test.scm, and () is the result of the evaluation of the file.

forthlisp's People

Contributors

schani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

forthlisp's Issues

License?

Hi! Was curious - is there a license assigned to this code?

unloop, a trifle bizarre

I see an unloop in symtab-lookup. My conclusion is that it goes up two levels in the call chain.
A somewhat bizarre tail-call optimization.

You've have a very nice and portable program. With this you have triple environmental dependancy

  1. a classical usage of the return stack for call addresses
  2. the return stack is used for do loop parameters
  3. do loop parameters occupy exactly two places

I had a hard time debugging it in lina because of 3. lina has 3 places for the loop parameters

In terms of clarity you program scores 9 or 10. The unloop makes it somewhere near 4.
So my advice, just leave out this unloop .

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.