guile-devel
[Top][All Lists]
Advanced

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

Re: [patch] First round (request for discussion)


From: Daniel Skarda
Subject: Re: [patch] First round (request for discussion)
Date: 31 May 2001 12:49:21 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

> >   But nobody replied so I started to play with guile source code - I tried 
> > to
> > not shoot myself in foot and finally it is working!
> 
> Sorry for being slow.  Having setters on smobs is a good idea since
> they can be used as getters already.  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. Maybe we could make it optional feature (with some switch to
 turn it on/off) and create an agreement that it is prohibited to use it in
 guile system files (ice-9/*, srfi/* etc) - guile developers should use *-ref
 and *-set! procedures instead.
 
 On the other hand adding setter/getter feature to guile is quite cheap (and
 imho clean) and sometimes it can be useful.

> >   So my patch modifies generalized set! macro, replaces `setter' call by
> > `setter-apply' and you can do this:
> 
> 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

    or
 
       ((setter m) a1 a2 v)             ;;; m is procedure with setter

  but unfortunately we can not determine it during macro expansion, because it
depends on the type of m (which is not known). The decision is left to
apply-setter.

                                     -=-=-

  There are few issues I would like to solve:

   * I implemented smob setters in different way than smob getters. Getters are
     realized using pointer to C function, setters use scm_c_make_gsubr.

   * Implement getters for GOOPS objects? (I guess I should consult that with
     Mikael Djurfeldt.
  
   * Write ChangeLog :)

Dan



reply via email to

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