[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

collection classes



   Date: Fri, 18 Dec 92 18:09:25 EST
   From: moon@cambridge.apple.com (David A. Moon)

   ...  By the way in Dylan the new-value argument goes at the end ...

I previously proposed to change Dylan so that the new-value parameter
is first in the parameter list of a setter function.  I feel very
strongly about this and here's why.

The problem is felt when there are `#rest' args.  First, resulting
parameter lists are ugly:

  (define-method (setter aref) ((array <array>) #rest indices-and-new-value) ...)

Second, it is computationally expensive (in both time and space) to
strip off the new-value argument.  Maybe this wouldn't cost for
builtin functions like `aref' that have special compiler support, but
it will for user-defined setter functions with `#rest'.

Third, the new-value argument really doesn't belong there: it's
not part of the #rest args.

Fourth, there is no way to dispatch on the type of the new-value.  This
gets back to the response to one of my earlier comments by David Moon:

   Date: Wed, 30 Sep 92 15:57:04 EDT
   From: moon@cambridge.apple.com (David A. Moon)

   ...
   > Finally, now that Dylan has types, there are no rules for
   > type-checking.  For instance, what types of objects can someone
   > legally assign to another object of a given type.

   There is no operation in Dylan that assigns an object to another object.  
   Dylan does not have any operation like = in C++.

   I think you'll find that all of what you would call Dylan's type checking 
   rules are expressed in terms of method applicability.  That simplification is 
   quite intentional on the part of the language designers, I believe.

My point is that without an ability to define new-value's type,
there's no way to have the legality of assignment automatically
subsumed under method applicability.  

It seems to me that the only advantage to have the new-value parameter
at the end is that a `setter' function call would look very similar to
a `set!'.

  ((setter aref) a 1 2 99.0)  ~= (set! (aref a 1 2) 99.0)

I can understand that desire, but to me the price is too high and the
alternative is acceptable:

  ((setter aref) 99.0 a 1 2)

-- jonathan bachrach

IRCAM
31, rue Saint-Merri
F75004 Paris, France
011-33-1-44784096
bachrach@ircam.fr