Subject: Re: Scheme implementation in C++
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 21 Oct 2000 04:23:12 GMT
Newsgroups: comp.lang.scheme
Message-ID: <8sr5ng$1u0r$1@fido.engr.sgi.com>
Christopher Browne <cbbrowne@hex.net> wrote:
+---------------
| >What exactly is the point of implementing Scheme in C++?!?
| 
| There _are_ some reasons to do so:
| -> Using C++ classes might make it easier to implement it than it is
|    to do so using "just plain C structs."
+---------------

Unlikely. Scheme is already dirt-simple to implement with
"just plain C structs".

+---------------
| -> Judicious use of C++ exceptions _might_ make it easier to make the
|    implementation robust than the C equivalent that lacks C++ exceptions.
+---------------

What makes you think that C++ exceptions are any more "robust" than a
simple exception system (modelled, say, after MzScheme's or Common Lisp's)
implemented in C?

+---------------
| -> There might very well be some data structures that could be better
|    implemented as templates than via C structs.
+---------------

See the first answer. Understanding the sum total of C structs you'd need
to implement R5RS Scheme is probably easier than understanding even one
C++ template, I'm guessing.

+---------------
| But note that this does _NOT_ mean that the C++ data structures sit
| there "shining through" on the Scheme side of things; it just means
| that the bowels of the implementation might, _arguably_, receive some
| improved qualities.
+---------------

I'd start by studying a handful of decent C-based Scheme implementations
in depth (there are lots of open-source implementations to look at).
*Then* decide whether you think there's any need (or desire) for C++
in this application.

+---------------
| The problem with this is that the people that have the desire to
| understand C++ well enough to make "judicious" use of C++ functionality
| probably would rather implement systems in C++, not in Scheme.
+---------------

But who knows? Perhaps people who already understand C++ well enough
to make "judicious" use of C++ functionality actually understand enough
to not *want* to implement systems in C++, but in something better!

Or even (you think just maybe?) they might prefer to implement a Scheme
system in *Scheme* itself, including the compiler [targeting C code,
perhaps, if portabiliity is an issue].


-Rob

p.s. By the way, people have successfully glued major C++ functionality
to Scheme in the past. The Rice PLT DrScheme/MrEd package, for example
uses the C++-based wxWindows as its windowing toolkit, and interfaces
to it more or less directly from the underlying MzScheme, with a
set of glue routines that map the C++ classes in wxWindows to MzScheme
classes. Yet except for the wxWindows interface itself, almost all of
MzScheme is written in Scheme & C.

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043