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]

Setter argument order in getter-with-setters


Per Bothner suggests that setter argument order should be:

  (SETTER V A1 A2 ...)

The motivation is that the number of arguments can vary.
E.g., the argument order

  (SETTER A1 A2 ... V)

would be unfortunate for arrays, where the setter is

  (array-set! a V i1 i2 ...)

When we have argument order mismatch we need to wrap the setter in a
closure which fix the arguments.

The second convention means that the wrapper for array-set! will need
to do an explicit search in the argument list in order to locate V.
In this sense, the first convention is better than the second.

What is not nice about the first convention is that it is incompatible
with *all* currently existing setters.

Is there no other reasonable convention which would be compatible with
a larger set of currently existing setters?  It would be nice if it
would be compatible with two-arg and/or three-arg setters of the
set-car! and slot-set! types... ?

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?

/mdj