This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> > However, it would please me (if it's not too deadly to implement) to > > see functions allowed to return set!-able references: > > > (set! (my-prop) 17) > > (my-prop) => 17 > > Kawa supports this (for some primitive functions - I haven't decided > yet how to define such functions in Scheme). > > Note that having functions "return set!-able references" is > probably not the way to do it, since we want a normal call (not in a > set! context) to return plain value, not a reference. Instead, > we allow functions to have "attributes", and one attribute is a > functions setter function. Then we define: > (set! (f . args) value) > as being syntactic sugar for: > ((setter f) value . args) > > > (While I'm at it, I'd argue for (set! (array-ref a 6) 'zork) etc. as a > > clean alternative to setf.) > > The advantage of this design is that it is procedural, while > setf is macro-based. Hence setf only works for setter functions > explicitly known (by name) at compile time, but setter works on > procedure *values* at run-time, and is therefore much more in > the spirit of Scheme. I'd propose to look at EuLisp which has this functionality: (setter car) -> set-car! so one uses: (set l '(1 2 3 4)) (car l) -> 1 ((setter car) l 5) -> '(5 2 3 4) The setter for a function can be set using: ((setter setter) car set-car!) -- Wolfgang Kechel Email: wolfgang@prs.de Patzschke + Rasp GmbH Bierstadter Str. 7 D-65189 Wiesbaden Phone: +49-611-1731-26 FAX: +49-611-1731-31