Juergen Boemmels <[EMAIL PROTECTED]> writes:
> Piers Cawley <[EMAIL PROTECTED]> writes:
[...]
>> typeof is a *really* bad idea. Let the 'Object' PMC handle the
>> multilevel vtable look up (in exactly the same way that one does
>> lexical lookup in the environment chain) and method invocation. So,
>> for instance, the bare Object would have no 'cdr' method, so to do
>> C<< call_method Pn, 'cdr' >> would throw an exception. But then one
>> could do

[...]

> Intresting aproach. Doing Scheme object oriented. I have to think
> about this approach another day.

I lifted the idea from a scheme in scheme implementation I found in
_The Seasoned Schemer_ which used functions for *everything*,
including pairs, so things like car and cdr became:

(define (car obj) (obj 'car))
(define (cdr obj) (obj 'cdr))

This had the advantage of allowing for new types to be added easily as
the implementation got extended; just implement another generic
function. The approach translated almost trivially to OO.

>> The thing is, we're going to need a Class/Object structure along these
>> lines for Perl/Ruby/Parrot objects anyway, so even though scheme won't
>> expose these PMCs to the end user, the effort in implementing them is
>> definitely worth while. And I think the extra code organizing
>> capability they give us is really important.
>> 
>> Note too, that it wouldn't be hard to set up SchemeFunc, CompiledSchemeFunc
>> and NativeFunc (he said, guessing at names) so that they all looked
>> like Sub PMCs when it came to function call time...
>>
>> NB: I have a proof of concept scheme interpreter running in Perl that
>> uses these OO techniques, and it works really neatly, which is why
>> I've been thinking of doing the Parrot scheme interpreter in a similar
>> fashion. 
>
> I would be very intrested to hear more about this interpreter

I'll see about stripping it down (it does *scary* stuff with C<redo
LABEL> to get tail call optimization) to the basic objects and a
simple minded interpreter then (if I can find the source...). Who
knows, maybe we can port it to functional style perl 6 faster than we
can implement it in raw parrot.

-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?

Reply via email to