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] |
jglascoe@jay.giss.nasa.gov writes: > YO, Maciej! I got your "set!" right here pal! > > On Fri, 6 Nov 1998, Maciej Stachowiak wrote: > > > > > jglascoe@jay.giss.nasa.gov writes: > > > > > > the big three basic operations: > > > > > > dictionary-insert! > > > dictionary-lookup > > > dictionary-remove! > > > > > > > In my opition, consistency is even more important than > > meaningfulness. Hence, these should be renamed to `dictionary-set!', > > `dictionary-ref' and `dictionary-delete!' respectively. > > > Imagine that we're choosing names for generic methods on collection data > structures... now, what's wrong with this picture: > > (set! vector 0 "foo") > (set! vector 0) ;; oops, forgot the third argument, I'm screwed now! > If I were changing the language radically enough that making (set! vector 0 "foo") were legal, I'd instead opt for making the syntax be (set! (vector-ref vector 0) "foo") That's the solution that Common Lisp takes essentially, and there is no ambiguity or vast potential for error here. Or, assuming you had a generic "ref" (maybe "index" would be a better name in a generic function world, assuming indexing by integer is distinct from looking up by an arbitrary key or something, or maybe "dereference" if you want to be anally correct) : (set! (ref vector 0) "foo") In other words, if you want to make everything generic, setting a location that you can get in some way should be made generic. > > Too bad they weren't thinking of generic functions when they dreamed up > the dual meanings of "set!". > set! doesn't have a dual meaning, `vector-set!' and `set!' are separate operators that are similarly named but do different things. If I wanted to design a generic function universe within Scheme I wouldn't do it the way you said, so this similarity would not be an issue. Assuming I wanted to leave the non-generic functions in, I'd be consistent in naming non-generics for other things that had them though. - Maciej