[racket] Writing a toy interpreter. Need help solving this bootstrapping problem.

From: Tony Garnock-Jones (tonyg at ccs.neu.edu)
Date: Thu Feb 17 09:11:38 EST 2011

Hi Patrick,

As others have said, it's likely that things like the symbol "new" will 
need to be constructed ahead of time by the interpreting system itself 
as part of its bootstrapping phase, while it gets ready to read and 
process user programs.

You might enjoy the following paper:

I. Piumarta and A. Warth, "Open, extensible object models," 2007. 
http://piumarta.com/software/cola/objmodel2.pdf

In it, the authors build up a simple object model from the bare metal. 
Particularly relevant to your question is Figure 12 and the associated 
text, where they bootstrap their object model to the point where 
ordinary (i.e. non-meta-level) functionality can be added to the system.

Regards,
   Tony



On 2011-02-16 11:07 PM, Patrick Li wrote:
> Hello everyone,
>
> I'm writing a toy Scheme-ish interpreter for fun, and am trying to add
> some Smalltalk flavor to my Scheme system. I'm running into a
> bootstrapping problem though, and would like to ask someone for a nudge
> in the right direction.
>
> (1) I want symbols to be represented as Functions.
> ie. I want to be able to do this:
> ('my-symbol 'length) returns 9
> ('my-symbol 'equals 'my-symbol2) returns false
>
> (2) I want symbols to be created by calling the function SYMBOL:
> (SYMBOL 'new <internal-symbol-representation>) returns a new function
> representing a symbol
>
> (3) I want users to be able to override the built-in SYMBOL function.
> (define SYMBOL (lambda args .... new symbol definition ....))
>
> I can't seem to write a system like this without falling into an
> infinite loop somewhere.
>
> For example this is the last one that I ran into:
>
> i. (quote asdf) is a special form that should create a symbol by calling
> (SYMBOL 'new <internal-object-which-represents-asdf>)
>
> ii. But doing that requires creating the 'new symbol
>
> iii. Creating the 'new symbol requires calling
> (SYMBOL 'new <internal-object-which-represents-new>)
>
> iv. But doing that requires creating the 'new symbol
>
> and so on.
>
>
> I apologize if this seems unclear. Please ask me for clarifications if I
> didn't explain myself properly. I have been stuck on this sort of
> problem for a while now, and can't wrap my head around it.
>    -Patrick
>
>
>
> _________________________________________________
>    For list-related administrative tasks:
>    http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.