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: Generalized set!



> > For most users, it shold not matter which we choose.  They will
> > use the generalized set!, but are unlikely to define new setters
> > themselves.  Most setters functions have fixed arity, so which
> > end to add the rhs does not matter.  The tradeoff is:
> > 
> > * Putting the rhs last is perhaps more natural.  It is certainly
> > more consistent with most existing Scheme fucntions.  It also
> > allows the implementation to use exising xxx-set! functions
> > as (setter xxx) without an intermediate step.
> > 
> > * On the other hand, putting the rhs first works a lot better
> > for varags functions, and is much more consistent with how
> > most varargs functions are used and defined.
> > 
> > There is no definite "correct" answer; we have conflicting
> > tradeoffs.  I do want to make sure people are aware of those
> > tradeoffs.  Kawa puts the rhs argument first, to the extent
> > that is relevant, though I guess I might be convinced to
> > change it.
> 
> This is a good description of the situation.
> 
> I don't have any further arguments.
> 
> I just turned it around in my head for several days, then settled for
> your proposal, implemented it, started to use it, and then just got
> this feeling that this is not how I'd like a scheme interpreter to
> behave.
> 
> *All* aspects of RnRS are so beautiful and intuitive.  When you read
> it the first time you just become so happy.
> 
> It is my subjective view that the second transformation above would
> break against that pattern.
> 
> I'll leave this for Jim to decide, either by himself or with a poll.

*I* have to decide???  Ugh.

I looked at Common Lisp, and I was not disappointed.
define-setf-method is utterly baroque.  The closest thing to our
situation is the simple form of defsetf, which passes the rhs last.
(This has probably already been mentioned.)

One should also note that passing the RHS last makes it impossible to
use setters that take optional arguments, unless you always supply
them.

Our setters are all based on underlying procedures.  Most existing
setter procedures place the RHS last.  If we pass the RHS first, we
will have to write adapters for all those functions.  Furthermore,
this will encourage some authors to simply write their setter
procedures to accept the RHS first (for ease of use with generalized
set!), leaving folks who don't like generalized set! with a bunch of
setters with very inconsistent calling conventions.

However, if we pass the RHS last, we will be able to use RnRS-like
setters unchanged.  We will only need to write adapters for functions
that are dissonant with RnRS, or which take a variable number of
arguments.  Such adapters could even handle functions that take
optional arguments:

  (define (foobie-adapter . args)
    (let ((indices (drop args -1))
	  (rhs (last args)))
      (apply foobie rhs indices)))

or whatever is appropriate for foobie.

So, on the principle that one should only have to go out of one's way
to accomodate oddities, and that if you follow existing conventions,
things should go well for you, ...

I think we should go with RHS last.