[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] First round (request for discussion)
From: |
Marius Vollmer |
Subject: |
Re: [patch] First round (request for discussion) |
Date: |
02 Jun 2001 02:41:04 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102 |
Daniel Skarda <address@hidden> writes:
> > However, making vectors and strings and maybe all kinds of stuff
> > into getters and setters is certainly appealing, but I'm not sure
> > whether it is a good idea in general.
>
> Yes. Using getters/setters makes scheme written for Guile less
> portable, moreover setters/getters can make scheme sources code a
> little bit obfuscated and hard to maintain.
I'm leaning towards not allowing getters/setters on all container
types. It somehow feels wrong to me. On the other hand, it also
feels somewhat natural.
> On the other hand adding setter/getter feature to guile is quite
> cheap (and imho clean) and sometimes it can be useful.
Maybe we could avoid hard coding it into the core and introduce a
bad-procedure hook. Ideally, that hook would be a generic function
(and setter would also be a generic function). Let's say we have a
generic function `apply-object' that is used to invoke every object,
including procedure. We could then add getters for strings like so:
(define-method (call-object (s <string>) index)
(string-ref s index))
This can be made efficient (for the usual cases) in the same way as
`+' has been made into a generic function.
> > I think `apply-setter' should be provided in addition to `setter'.
>
> Initially I wanted to extend only `setter' - but that is not
> possible. As you can see in my patch `setter' does not handle all
> types as apply-setter does. The main reason for this incompleteness
> is the need for additional function (setter-type) or an extension to
> `setter'.
>
> (set! (m a1 a2) v)
>
> "expands" to
>
> ((setter m) m a1 a2 v) ;;; m is smob with setter
The setter for smobs could be defined as a closure, I think:
(define (get-smob-setter obj)
(lambda args
(apply apply-setter obj args)))
`apply-setter' would not need to explicitly construct this closure,
and it is OK when `set!' expands into a call to `apply-setter'.
> * Implement getters for GOOPS objects? (I guess I should consult that with
> Mikael Djurfeldt.
You can already make classes that can be invoked. Use
<operator-class> as a meta-class. Don't know about setters...
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [patch] First round (request for discussion),
Marius Vollmer <=