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]

Re: Setter argument order in getter-with-setters


Maciej Stachowiak <mstachow@MIT.EDU> writes:

> > Example:
> > 
> > It is common that the first argument is a data structure.  Then one
> > could use the convention:
> > 
> >   (SETTER A1 V A2 ...)
> > 
> > which would be compatible with set-car!, array-set! and Goops getters.
> > 
> > Opinions?
> 
> That would still be incompatible with `vector-set!' and `string-set!'
> from RnRS, `list-set!' from Olin Shivers' list-lib proposal, and many
> other Guile getter-setter pairs where the setter is typically called
> as (setter! data-structure field-specifier value) [such as hash-set!,
> set-object-property!, setters generated for record types, and I'm sure
> many others].

Yes.  It is ahard to come up with a proposal that satisfies all
setters.  Note that the current suggested argument convention is the
one Kawa uses:

  (SETTER V A1 ...)

It is incompatible with *all* setters, but is still a consistent
alternative.

> It seems a shame to require so many setters (including
> standard ones) to be wrapped in a closure just for the sake of
> supporting array-set!'s weird argument order efficiently. Indeed, I
> can't think of any case _but_ array-set! that needs this support.

You have set-cxr! and Goops setters.  (I'd very much like Goops
accessors to be efficient.)

> I'd rather see the argument order of array-set! get changed if it
> comes to that,

Could you investigate this issue?  Would it be inefficient?  What
other changes would be required in the array support?  Do we have any
precedents in other Scheme interpreters?

> although that probably just offloads the work of munging the rest
> argument from a setter wrapper to array-set! itself (depending on
> how those args get processed), either that or just live with the
> inefficient array-set! wrapper. Normal Scheme practice is to have a
> matching setter take the same args as the getter with the value
> tacked on at the end.

I take it that you propose the

  (SETTER A1 ... V)

convention?

/mdj