Re: Minimal keywords needed for constructing a full CL system
- From: Lars Brinkhoff <lars.spam@xxxxxxxxxx>
- Date: Sat, 15 Jul 2006 15:09:17 +0200
rpw3@xxxxxxxx (Rob Warnock) writes:
So I'd like to suggest that a starting set of semantics for a
"minimal CL" include at least the following:
I've implemented much of CL in Emacs Lisp, which has a much smaller
set of primives than CL. You could even subset Emacs Lisp and use
that as an implementation substrate, which would get us a lot closer
to a "minimal" subset.
- At least one of the set of non-local control transfer primitives
sufficient to implement the rest, i.e. GO, RETURN-FROM, THROW, and
their establishing forms TAGBODY, BLOCK, & CATCH.
Right. Emacs Lisp only has catch and throw.
- The CL exception system, minimally [Kent might suggest a better set]
MAKE-CONDITION, SIGNAL, HANDLER-BIND, RESTART-BIND, FIND-RESTART, and
INVOKE-RESTART.
None of these are primitive. The binding forms can just add some
information to a dynamic variable. SIGNAL and FIND/INVOKE-RESTART
search that information and calls a closure. MAKE-CONDITION can be a
thin layer on top of MAKE-INSTANCE. (And all of CLOS can be
implemented from more primitive constructs.)
- The full numeric tower: Reals [float, rational, integer (fixnum
and bignum)] and Complex [pairs of those] and the usual related
functions.
Emacs Lisp only has fixnums and floats. In my implementation, all
other types of numbers are built from those. Of course, floats could
be implemented with fixnums.
- Lists (of course!), symbols/packages, characters, vectors (including
strings), structures, and enough hooks to add fully-general arrays
later.
It's enough to build up from conses, symbols, and vectors. Emacs Lisp
has more data types, which is useful, but not necessary. I guess
vectors could go if you don't need their O(1) properties.
You don't need hash tables, but weak hash tables are very very handy,
and I don't see how those could be implemented outside the core.
I *think* that's all you absolutely need in terms of datatypes to
later add CLOS, say, using PCL.
Yes, or almost. In my implementation, instances of many built-in
types, classes, and structures are vectors where the first element
indicates the type. You may want funcallable instances, but they are
not absolutely necessary.
- CLHS 3.2.2.2 "Minimal Compilation", so you can at least have macros
that only expand once. [If you're going to build up everything from
some minimal core, you need this to avoid horrible inefficiencies.]
You do need minimal compilation, but the (minimal) compiler can be
written in the core language. If you consider bootstrapping a solved
problem, I don't think the compiler is a necessary primitive.
- CLHS 3.3.1 "Minimal Declaration Processing Requirements", which
[to me] also implies "doing the right thing" with dynamic and
lexical scoping, including special variables in LAMBDA lists.
Declaration processing is just part of the compiler. You need one
kind binding: lexical or dynamic. Or maybe none at all, just
assignment to memory locations.
- Places & DEFINE-SETF-EXPANDER & a basic set of SETF/INCF/etc.
These are quite easy to write in the subset language.
.
- Follow-Ups:
- Re: Minimal keywords needed for constructing a full CL system
- From: Rob Warnock
- Re: Minimal keywords needed for constructing a full CL system
- References:
- Minimal keywords needed for constructing a full CL system
- From: Javier
- Re: Minimal keywords needed for constructing a full CL system
- From: Rob Thorpe
- Re: Minimal keywords needed for constructing a full CL system
- From: Don Geddis
- Re: Minimal keywords needed for constructing a full CL system
- From: Rob Thorpe
- Re: Minimal keywords needed for constructing a full CL system
- From: Rob Warnock
- Minimal keywords needed for constructing a full CL system
- Prev by Date: Re: Silly argument for a unix DIRECTORY:
- Next by Date: Re: Reader macros list?
- Previous by thread: Re: Minimal keywords needed for constructing a full CL system
- Next by thread: Re: Minimal keywords needed for constructing a full CL system
- Index(es):