John Cowan: 
> I don't understand the purpose of this second point.  Common Lisps
> do not understand these "long names", and expect the reader to
> fully expand quasiquote notation into calls on either standard or
> implementation-specific procedures, without any standardized syntax layer.
> Thus `(a ,b) does not become (quasiquote (a (unquote b))), but something
> like (list (quote a) b) directly.

Quite so.  I'm actually familiar with this, and the usual algorithm is actually 
quite complicated (one hairy implementation is in Steele's book, IIRC).  To 
have sweet-expressions FULLY and PROPERLY work in Common Lisp (CL), someone 
will have to re-implement a sweet-expression processor in Common Lisp.  We even 
have a starting prototype in CL!

However, the CL prototype is nowhere near a full implementation, and I just 
don't have time to do that implementation as well.  Any takers?

Since I have limited time, I've decided to focus mostly on implementing these 
notations on one Lisp dialect, and I've chosen Scheme as that dialect.  I've 
written a fair amount of code in CL and its predecessors over 30 years (more 
than Scheme), and CL it has some real advantages in terms of standardized 
capabilities.  But I think Scheme is a cleaner and more pleasant language to 
write code in, and since no one's paying me for this, I'd rather do something I 
enjoy.  Also, I think it's easier to go from Scheme to CL than the other way.

Aside: If only those crazy Schemers would create a module system, a set of 
"batteries included" library modules, and an exception handling system that was 
clearly specified and was implemented by "all the major Schemes".  Then you 
could write "practical" big Scheme programs that actually ported between 
implementations!!  I think that'd be really great.  I hear they're working on 
that :-).

So... what I want to do is use the existing *Scheme* implementation to do a 
*partial* job for CL, with relatively little implementation effort based on 
where we are now.  Think of it as a prototype for this purpose - something that 
would work for many cases, and let people try it out.  I know of at least one 
person who'd be interested if we could handle CL, even if it was only to a 
limited degree.

The "unsweeten" program could do this by reading ` as quasiquote (it already 
does that), and printing ` for quasiquote.  That latter step is perfectly fine 
for Scheme.  If that is then sent to Common Lisp via pipe or file, it'll work 
quite well.  As you note, the implementation will *not* actually splice in the 
lists, execute, and so on.  But that's okay; the underlying Common Lisp 
implementation can already read ` (etc.) and do the right thing, we can just 
reuse their implementation.

Currently, you can already do this:
unsweeten | clisp
You can get a *lot* working, even though it's really the "wrong reader"... 
defun, simple lists, quote, and other things all just work.  E.G., this works 
just fine right now:
defun fact (x)
!  if {x < 2}
!    1
!    {x * fact{x - 1}}
fact 20

I think with a few tweaks, we can make unsweeten work much better with Common 
Lisp and some other Lisps.  For Common Lisp, the main problem is that #' needs 
to mean function, and stuff like "quasiquote" needs to be printed as ` by 
unsweeten (so it can pass that text on to Common Lisp). We should probably make 
it possible to print weird symbols like "1+" as |1+| instead of the 
guile-specific #{1+}.  My thought is we could add an option to "unsweeten" to 
make it do that, when needed.  It shouldn't take much code at all.  Obviously 
the underlying list structure wouldn't be the same, but the CL implementation 
wouldn't see that, it'd just see what looks like normal textual s-expressions.

Yes, this is imperfect, and the facade is easily broken.  E.G., if a Common 
Lisp user enters (quasiquote c d), the unsweeten program would generate `(c d), 
which would be a completely wrong translation to Common Lisp.  But I think it's 
likely to work pretty well in practice, especially if you write code that 
sticks to the notational subset common between Common Lisp and Scheme.  It's 
enough to make it a useful preprocessor for a lot of real programs.

--- David A. Wheeler

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to