[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is a lightweight language
> Date: Fri, 7 Dec 2001 10:43:10 -0500 (EST)
> From: Dan Weinreb <email@example.com>
> Date: Thu, 6 Dec 2001 16:42:26 -0400
> From: firstname.lastname@example.org
> Full Common Lisp? No, not lightweight. A simple Scheme? Definitely
> It would be interesting to analyze Common Lisp and figure out the
> smallest subset that you could (reasonably) create such that the rest
> of Common Lisp could be provided in the form of functions and macros
> build on the subset. That is, if you factored out everything in
> Common Lisp that could be considered part of the "libraries", what's
> All you need to write is a simple s-exp parser, a simple GC,
> and implementations of the "big five" basic forms:
> Scheme is a very small language!
> Is that really all you need? What happened to call/cc? What happened
> to integers and strings and vectors? What about "cond" and "let" and
"cond" can be defined as a macro if you have "if". "let" can be defined as
a macro if you have "lambda". I'm pretty sure "apply" has to primitive,
but very little code actually needs "apply". I don't know how call/cc
could be implemented in terms of the big five, so I leave that as an
exercise for the reader ;-) Of course, even "define" can be omitted if you
have the Y combinator, but that's an exercise in masochism.
As for numbers, strings, and vectors, there is an interesting point here.
These are built in to most languages (though strings are sometimes not
built-in e.g. in C/C++). In scheme, they are built-in from the standpoint
of parsing, but the functions that operate on them are procedures which
happen to be built-in. So "+" is just a built-in procedure in scheme,
just like "sqrt". In most infix languages, "+" is built-in because it's an
operator, which requires special treatment, whereas "sqrt" is a library
procedure. This is why I like s-expression syntax: it's the most neutral
syntax I can imagine. It doesn't make any particular kind of operation
harder or easier than any other; everything is just a parenthesized list.