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] |
Greg Badros wrote: > > Why is it that assoc takes KEY ALIST, whereas assoc-ref (and all the > other guile alist procs) takes the arguments in the reverse order: ALIST > KEY? Is this historical? Since RnRS demands KEY ALIST, it seems it'd > be nicer if assoc-ref used the same ordering. Or at least the > documentation (even in its minimalist form) should stress the order of > these args as being unusual. I don't think this is the first time I've > been confused by them. The problem is that assoc's argument order is unusual compared to other accessors, which usually DATA-STRUCTURE KEY for getters and DATA-STRUCTURE KEY VALUE for setters. `assoc' is different in part because it is not a normal accessor; instead of getting the value associated with the key it gets the associated key-value pair. IMO it's more useful for `assoc-ref' to be consistent with `vector-ref', `string-ref', `list-ref', etc than for it to be consistent with `assoc'. - Maciej