[comp.lang.scheme] Scoop for Scheme->C?

sidlo@APS.Atex.Kodak.COM (John Sidlo) (05/22/91)

Has someone ported the TI scoop to Scheme->C?  It would be nice if there
were a pure Scheme implementation of it.


--
John Sidlo                    <sidlo@Atex.kodak.com>  Voice: 508-670-4024
Atex Advanced Publishing Systems                        Fax: 508-670-4033
Atex, Inc; 165 Lexington St. MS 400/165L; Billerica MA 01821

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (05/22/91)

In article <1991May21.173430.18323@APS.Atex.Kodak.COM>, sidlo@APS.Atex.Kodak.COM (John Sidlo) writes:
> Has someone ported the TI scoop to Scheme->C?  It would be nice if there
> were a pure Scheme implementation of it.

There is a copy of SCOOPS in the Scheme Repository (many thanks to Ozan
Yigit for maintaining the repository).  I took a long hard look at it.
The major problem in adapting it to other schemes is that it relies on
environments being first class objects that you can bend.  When you
have a class, you actually end up with two environments:
    -- a class environment that holds classvars (made when the class
       when the class is compiled)
    -- a methods environment that holds the methods defined on that
       class (_made_ when the class is compiled, _extended_ whenever
       a new method is defined).
When you have an instance of a class, you have yet another environment:
    -- an instance environment holding instancevars (made when the
       instance is created).
Now the trick is that methods can not only refer to classvars and
other methods for the same class without qualification, they can refer
to instancevars without qualification too.  How is that managed?
Simple:  when a method is invoked it twiddles the "lexical parent" links
of the three relevant environments so that the class and methods
environments are temporarily _inside_ the instance environment.  There's
some fancy footwork so that sending to another object of the same class
works without leaving environments in a tangle (where would we be without
unwinding?).

So if your Scheme implementation doesn't provide environments as first
class objects whose lexical parent links can be bent, you can't make
SCOOPS work.  Environments aren't in the Scheme standard.

-- 
There is no such thing as a balanced ecology; ecosystems are chaotic.