Re: Minimal keywords needed for constructing a full CL system



rpw3@xxxxxxxx (Rob Warnock) writes:
Lars Brinkhoff <lars.spam@xxxxxxxxxx> wrote:
I've implemented much of CL in Emacs Lisp, which has a much
smaller set of primives than CL.
Very interesting indeed! Do you think your "much of CL" meets the
definition of a "subset of CL" given in CLHS 1.7 "Language Subsets"?

Absolutely. It's actually quite close to full ANSI CL, but some major
chunks are missing, like pretty printing and CLOS. Other than that,
it's just another implementation of 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.
Right, but consider the above comments on the relationship between
the implementation substrate and the "subset CL" which it hosts.

Ok, in that case, my implementaion uses Emacs Lisp almost exclusively
as a substrate, and the CL layer is a separate language on top of
that.

However, I believe you could take the Emacs Lisp language (not the
implementation) as a starting point, modify it somewhat, and get a
language that would be both a strict subset of CL, and a useful CL
implementation language. Or at least use Emacs Lisp as some kind of
guide to which features to include. Emacs Lisp is actually already
quite close to being a CL subset, at least culturally.

Emacs Lisp only has catch and throw.
In my "QDL", I'm probably going to use TAGBODY/GO as the "primitive"
one

Yes, that would have been my choise too.

- The CL exception system [...]
None of these are primitive.
O.k., fine. And as Kent has pointed out elsewhere in this thread:
...in an error system...really none of the functionality needs
to be primitive. This was already possible to write in portable CL.
What was not portable to write was the "fact" that it gets called.
So at least enough hooks have to be provided in the implementation
substrate

Right, but to pick nits, a substrate doesn't need those hooks (like,
provably, Emacs Lisp), but a subset does.

- 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.

It's that sticky little "equivalent semantics" clause that worries me.

By now, you should have realised (as have I) that I was writing about
something slighly different from what you was asking for. Of course,
most Emacs Lisp operators have wildly different semantics from the
corresponding CL operators. So Emacs Lisp hardly qualifies as the
subset language you want. However, it's quite straightforward to use
it to implement the CL semantics in a distinct set of operators.

But once you extend a fixnum-only subset to include floats, with
automatic coercion to floats for non-fixnum results, then I think
you can no longer claim to meet the "equivalent semantics" clause!!

No, but a fixnum-only subset wouldn't have to handle things that way.
By your suggestion, signals could be raised at appropriate points, and
handled to implement CL semantics.

And if Emacs Lisp is your implementation substrate, then the expression
(/ 3 5) ==> 0.6 would fail to have equivalent semantics in full CL.

But because Emacs Lisp is a *substrate*, not a subset, this doesn't
matter. In my CL implementation, (/ 3 5) evaluates to 3/5, as it
should. Obviously, the emacs-lisp:/ operator isn't the same as
common-lisp:/.

as you point out, from vectors come structs, and from structs, CLOS.

(Or structs come from CLOS, or they may be separate. Each way has its
merits.)

But if you do this, there may be problems with the subset semantics.
You wouldn't want the subset to say that TYPE-OF a struct is VECTOR.
Of course you can make the subset have its own operator, say
CL-SUBSET:TYPE-OF, and implement CL:TYPE-OF in terms of that, but then
a small part of your subset has been expatriated to substrate layer,
and then you have a situation that is similar to my implementation.

You don't need hash tables, but weak hash tables are very very handy
Just curious... How are weak hash tables more useful than generic
weak pointers?

I didn't say they are. I don't know enough on generic weak pointers
to comment on that.

Declaration processing is just part of the compiler. You need one
kind of binding: lexical or dynamic. Or maybe none at all, just
assignment to memory locations.
Well, mere "assignment to memory locations" doesn't provide the
right semantics for LAMBDA, and if you have LAMBDA, then almost all
the other binding constructs are just a hop, skip, & jump away.

Right. It's just the substrate vs subset thing again.

I'm still curious as to whether any CL implementors or serious users
have an opinion/belief/hunch about whether a "useful" subset of CL
exists that meets CLHS 1.7...

I believe Lisp500 may be quite close to such a subset. When I last
looked at it, it really seemed to go out of its way to only implement
the most necessary primitives in C, and add more CL operators in a
Lisp initiation file.
.



Relevant Pages

  • Re: Minimal keywords needed for constructing a full CL system
    ... | I've implemented much of CL in Emacs Lisp, ... I'm particularly concerned about the "equivalent semantics" clause ... language which meets all of the following criteria: ... |> - At least one of the set of non-local control transfer primitives ...
    (comp.lang.lisp)
  • Re: what does "Scheme is a statically scoped programming language" mean?
    ... Yes, for example emacs lisp. ... a "non-statically scoped" language. ... It adds closures, that is self contained functions, and ease the ...
    (comp.lang.lisp)
  • Re: Minimal keywords needed for constructing a full CL system
    ... |>> mathematical quotient of two integers is not an exact integer. ... I have used Emacs Lisp as the implementation ... | the differences between / in Emacs Lisp and Common Lisp to be a hard ... It's probably on par with using, say, C as a substrate, ...
    (comp.lang.lisp)
  • Re: Minimal keywords needed for constructing a full CL system
    ... mathematical quotient of two integers is not an exact integer. ... I have used Emacs Lisp as the implementation ... substrate of a conforming CL subset, ... the differences between / in Emacs Lisp and Common Lisp to be a hard ...
    (comp.lang.lisp)
  • Re: Lisp is Sin
    ... > favourite programming language?! ... I've learned a number of programming language, ... I've even started to design my own languages. ... I started to use emacs lisp and Common Lisp and found the ...
    (comp.lang.lisp)