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] |
> That is why Kawa has the new value first in the setter: > (set! (PWS A1 ...) V) --> ((SETTER PWS) V A1 ...) > > 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. Maybe the setter functions should be called ``put!'' functions to distinguish them from existing set! ordering and so that you can read: (vector-put! item vec 3) as ``put item into vector slot 3'' > 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. My own functions have become pretty haphazard with their argument ordering but I do tend to put the value last. Not for any particular reason just because it seemed so at the time. I don't currently HAVE any setter function that has optional arguments but I can immediately think of one that I could use if I swapped the ordering around. That is for matrix SMOBs, I'm currently using: (matrix-set! matrix row col value) And when matrix is a column vector only, I just use: (matrix-set! matrix row 1 value) These could be slightly tidier if they changed to: (matrix-put! value matrix row col) and (matrix-put! value matrix row) So I must say that my code would probably benefit from putting the value first. It would certainly benefit if someone came up with a general guideline regarding how arguments should be ordered and why (presuming such a guideline made sense) because being consistent in such things seems the most important issue. - Tel