[plt-scheme] Convention for alists?

From: Doug Orleans (dougo at place.org)
Date: Sat Apr 2 22:16:23 EST 2005

Richard Cobbe writes:
 > Is there a commonly-accepted convention for the shape of an association
 > list?  I've seen both
 >     '((a . 3) (b . 4) (c . 5))
 > and
 >     '((a 3) (b 4) (c 5))
 > before.
 > Clearly, the R5RS primitives will work on both, as will assf from
 > etc.ss; it's just a question of how one extracts the values.
 > (Here's the context: my environment library, in PLaneT/300, exports an
 > env->alist function that returns a list of the second form above.
 > Should I change it to the first?)

I tend to prefer the first, and SRFI-1's `alist-cons' seems to
encourage it also.  I think the second form is mainly used for literal
alists, because the representation is shorter, but of course the
former uses less memory (or no more memory-- I guess in a cdr-coded
implementation they'd be the same).

--dougo at place.org

Posted on the users mailing list.