masak / bel

An interpreter for Bel, Paul Graham's Lisp language
GNU General Public License v3.0
27 stars 1 forks source link

Show the globals as they are defined #168

Open masak opened 4 years ago

masak commented 4 years ago

The global functions and macros that end up in Globals.pm currently still serve two masters a little bit:

I would like for this to happen:

> all
(def all (f xs)
  (if (no xs)      t
      (f (car xs)) (all f (cdr xs))
                   nil))

That is, I would like for the value of (e.g.) the all built-in to be printed exactly the way it is in bel.bel.

I mean "exactly the way" in two different senses: (a) exactly those program parts, (b) indented exactly that way.

This could happen in two ways, as far as I can see:

  1. Either store the global functions and macros as strings with the above layout. Generate (and cache) their actual cons cell values whenever someone is curious enough to destructure them.

  2. Or store the cons cell values, but have a way to pretty-print the functions and macros, reproducing the structure in bel.bel exactly.

The first way sounds easier. Maybe it's even more efficient, once we make the loading lazy enough.

masak commented 4 years ago

Suggest doing this one right after #198.