bel icon indicating copy to clipboard operation
bel copied to clipboard

Show the globals as they are defined

Open masak opened this issue 5 years ago • 1 comments

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

  • They are slightly preprocessed by the bquote expander (for speed, but also because we don't have Bel's macro-based bquote expander yet)
  • They are output to screen when someone asks for them

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 avatar Jun 10 '20 07:06 masak

Suggest doing this one right after #198.

masak avatar Jul 15 '20 09:07 masak