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

Re: A Proposal!!



It's a silly proposal if you insist on using add! for everything.

Implicit in my suggestion was that for the equivalent of cons on a
lists you would use add.  There would be no such thing as add! on a
non-stretchy vector (an error would be signalled).  

As far as the "long history of LISP programming", I was thinking of
Scheme, which uses this convention for lists and vectors (but of
course is not OO).

That said, I'm not really convinced my proposal is a good idea -- it
trades one improvement (consistency in function names and eq-ness) for
other problems.  add! would no longer be implemented on <sequence> but
rather on <stretchy-collection> -- thus losing some generality (and
causing lots of existing code to break, no doubt).

>>>>> "Bruce" == Bruce Hoult <brucehoult@pobox.com> writes:

 Bruce> In article <uvqitw7jsyw.fsf@ernie.ai.mit.edu>, gregs@ai.mit.edu (Gregory
 Bruce> T. Sullivan) wrote:

 >> Why not say that all !'ed versions _must_ maintain eq?-ness and all
 >> non-!'ed versions _never_ side-effect the existing object?  

 Bruce> Because that's silly.

 Bruce> How are you going to do that with a list?  The efficient thing to do with
 Bruce> a list is to create a cons cell, put the new data in it, point it at the
 Bruce> existing list, and return the new cell.  The only way to make it == the
 Bruce> existing list would be to traverse the list down to the end and add the
 Bruce> new element there.  Or at least add it as the second element.

 Bruce> Making add! return an == thing on a non-stretchy vector is plain impossible.

 Bruce> The way it is now is fine and comes from a long history of LISP
 Bruce> programing.  Wihtout ! is pure functional -- doens't affect the arguments
 Bruce> -- and with ! is allowed to do whatever it wants with whatever is fastest
 Bruce> being king.

-- 
Greg      gregs@ai.mit.edu (617)253-5807
Sullivan  http://www.ai.mit.edu/~gregs/


References: