[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Message Passing with GOOPS
From: |
Michael Tiedtke |
Subject: |
Re: Message Passing with GOOPS |
Date: |
Fri, 26 Jun 2015 12:15:07 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 26/06/2015 10:18, Ralf Mattes wrote:
...
This is a first "raw" definition where the parameter /message/ has to be a
quoted symbol.
(define-method (call (receiver <object>) message . arguments)
(apply (slot-ref receiver message) arguments))
The class definition still looks like traditional GOOPS but it works.
An example:
(define-class <receiver> ()
(msg #:init-value (lambda () 'hello-world)))
(define r (make <receiver>))
(call r 'msg) => 'hello-world
Now I'd like to have an easier syntax for describing the slot. The
definition might be:
(define-syntax define-message
(syntax-rules ()
((_ (message-name arguments ... ) body ...)
(message-name #:init-value (lambda (arguments ...) body ...)))))
But the following example doesn't work in 1.8:
(define-class <house> ()
(define-message (phone n)
(repeat n (lambda () (bell) 'rang)) ))
GOOPS complains about malformed slots and *seems* to see the unexpanded
form.*
Here:
$ guile-1.8
guile> (use-modules (oop goops))
guile> define-class
#<macro! define-class>
Why would you expect a macro to evaluate its arguments? :-)
The use of macros within macros is yet to be evaluated. But as syntax
transformers sometimes check their arguments before these expressions
are expanded if they are macros - one should really think about Scheme's
macro expansion model.
Do you think syntax transformers have in any way anything to do with the
evaluation of code?
I could use a little help here, anyone?* Even for the naming scheme: /send/
is already used by unix sockets and methods are part of the implementation
of generics. Perhaps /message/ isn't that bad.
That's what modules are for.
guile> (define-module (ios) #:export (send)) ; ios = Inferior Object System
and then:
guile> (ios:send ....)
Yes, just call it r-0b-delta-36x7 and let people rename it to find out
what it means.
[...]
PS
Perhaps it's better to recreate a clean object model without 3,000 lines of
C code like GOOPS. But then GOOPS really creates the illusion of an object
oriented environment with a MOP ...
Why, 3000 lines of C code seems like a rather lean codebase for an objet system.
Seems like your sentence is not a valid expression in Scheme.