From: Ralf Mattes <rm@seid-online.de>
To: Michael Tiedtke <michele.titke@o2online.de>
Cc: "guile-user@gnu.org" <guile-user@gnu.org>
Subject: Re: Message Passing with GOOPS
Date: Fri, 26 Jun 2015 10:18:27 +0200 [thread overview]
Message-ID: <20150626081827.GA12072@seid-online.de> (raw)
In-Reply-To: <558B1158.4020607@o2online.de>
On Wed, Jun 24, 2015 at 10:21:44PM +0200, Michael Tiedtke wrote:
> (use-modules (oop goops))
>
> GOOPS has some nice features (you can even use unexported methods with
> generics in 1.8) but there is no message passing paradigm.
Guile's GOOPS is a (rather impressive) clone of CLOS, the Common Lisp Object
System. I such a system functions/methods don't "belong" to a class.
> Objective-C has
> /tell/ Racket has /send/ but Guile/GOOPS is missing /call/.
Message passing only exists in object systems where methods belong to
a class/object. Generic functions don't "belong" to a class/object.
If you really want to use a far inferior OO system you might want to port
Common Lisp's Flavour system :-)
>
> 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? :-)
> 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 ....)
> [...]
> 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.
Just my 0.2 $
Ralf Mattes
next prev parent reply other threads:[~2015-06-26 8:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 20:21 Message Passing with GOOPS Michael Tiedtke
2015-06-24 22:07 ` Marko Rauhamaa
2015-06-25 6:30 ` Michael Tiedtke
2015-06-25 9:07 ` Marko Rauhamaa
2015-06-25 10:59 ` Michael Tiedtke
2015-06-26 8:18 ` Ralf Mattes [this message]
2015-06-26 9:26 ` Marko Rauhamaa
2015-06-26 11:13 ` Pascal J. Bourguignon
2015-06-26 12:21 ` Marko Rauhamaa
2015-06-26 10:15 ` Michael Tiedtke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150626081827.GA12072@seid-online.de \
--to=rm@seid-online.de \
--cc=guile-user@gnu.org \
--cc=michele.titke@o2online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).