guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: equivalent of "this" in goops?


From: Neil Jerram
Subject: Re: equivalent of "this" in goops?
Date: Wed, 16 Feb 2005 23:43:19 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050105 Debian/1.7.5-1

Andreas Rottmann wrote:
Greg Troxel <address@hidden> writes:

In a class representing a node, I want to have a slot with an
init-thunk, [...] So, I'd like to pass 'this' in c++ terms, and I don't see how 
to do
that from reading goops.info.

FWICT (not being a GOOPS expert), this is not possible without
extending GOOPS: the init-thunk of a slot is specified at class
creation time, and the earliest time "this" is avaiable is in the
"initialize" generic. However, since the init-thunk is called at
initialization time, "this" would be available at the time it is run,
but there is no way to pass it, since the init-thunk, is, well, a
thunk ;). I could imagine a init-function (name to be argued), which
gets passed all arguments from "initialize" could be a useful
extension.

Absolutely right. Your best bet at this point is to customize the initialize method for the class:

(define-method (initialize (this <node>) initargs)
  (next-method)
  (slot-set this 'name-of-slot-with-init-thunk
            (init-function this)))

(It's probably also possible to use the MOP to support #:init-proc as a new slot option, but that would require more thought.)

Regards,
        Neil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]