From: Clinton Hyde
Subject: Re: Legal forms in SETF?
Date: 
Message-ID: <CHYDE.92Jun19130054@pecos.ads.com>
(uh oh, the flamethrowers are heating up already)

;;BTW, the value of an association in an alist is usually retrieved with
;;CDR since the alist usually consists of dotted pairs.

i don't think i have EVER used dotted pairs in an a-list. suppose the
second part was a list? you can't make a dotted pair with one that
way. so assuming it IS a dotted pair could be wrong. safer, i think,
to NOT make them dotted, then you don't have potential probs.

 -- clint
--

Clint Hyde                      "Give me a LispM or give me death!" -- jwz

Advanced Decision Systems	Internet:  ·····@chesapeake.ads.com
2111 Wilson Blvd #800
Arlington, VA 22201		(703) 875-0327

From: Douglas Rand
Subject: Re: Legal forms in SETF?
Date: 
Message-ID: <DRAND.92Jun19154118@spinner.osf.org>
In article <···················@pecos.ads.com> ·····@pecos.ads.com (Clinton Hyde) writes:

   (uh oh, the flamethrowers are heating up already)

   ;;BTW, the value of an association in an alist is usually retrieved with
   ;;CDR since the alist usually consists of dotted pairs.

   i don't think i have EVER used dotted pairs in an a-list. suppose the
   second part was a list? you can't make a dotted pair with one that
   way. so assuming it IS a dotted pair could be wrong. safer, i think,
   to NOT make them dotted, then you don't have potential probs.

You should make them dotted and lists work fine.  It's true
that a dotted pair with a list as its second value prints as
a proper list,  but that doesn't change the validity of 
using cdr to extract it.

For example:

alist:  (("Cat" . "Dog")
	 ("Mouse" "mouse1" "mouse2" "mouse3"))

(assoc "Cat" alist) -> ("Cat" . "Dog") - cdr -> "Dog"
(assoc "Mouse" alist) -> ("Mouse" ...) - cdr -> ("mouse1" "mouse2" "mouse3")

--
Douglas S. Rand <·····@osf.org>		OSF/Motif Dev.
Snail:         11 Cambridge Center,  Cambridge,  MA  02142
Disclaimer:    I don't know if OSF agrees with me... let's vote on it.
Amateur Radio: KC1KJ
From: Barry Margolin
Subject: Re: Legal forms in SETF?
Date: 
Message-ID: <11tc7eINNgl5@early-bird.think.com>
In article <···················@pecos.ads.com> ·····@pecos.ads.com (Clinton Hyde) writes:
>i don't think i have EVER used dotted pairs in an a-list. suppose the
>second part was a list? you can't make a dotted pair with one that
>way. so assuming it IS a dotted pair could be wrong. safer, i think,
>to NOT make them dotted, then you don't have potential probs.

Existing CL functions that operate on a-lists assume that the value is the
CDR of the pair.  Look at ACONS, PAIRLIS, RASSOC, and COPY-ALIST.  New
functions should be consistent with these precedents, or confusion will
result.

And unless you're on a machine with cdr-coding, making the value be the
CADR instead of the CDR results in the a-list taking twice as much storage
(since it requires two cons cells per entry instead of one).

I don't understand your "suppose the second part was a list" question.
There's nothing wrong with the CDR of a cons being a list.  It won't print
in dotted notation by default, but what difference does it make?  BTW,
Symbolics GENERA allows *PRINT-PRETTY* to be set to :ALIST, in which case
it prints a list of conses using dotted notation for the sublists, e.g.

(write '((a b c) (d . f) (g h)) :pretty :alist)
prints
((A . (B C))
 (D . F)
 (G . (H)))

The interesting thing about this is that most a-lists inside Genera are
like yours, with the value being the CADR.  That's probably because those
data structures were designed before the :PRINT :ALIST was introduced, and
lists of lists look nicer than lists of dotted pairs.  And since Symbolics
machines have cdr-coding, there was no space penalty.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar
From: Bruce R. Miller
Subject: Re: Legal forms in SETF?
Date: 
Message-ID: <2917971320@ARTEMIS.cam.nist.gov>
In article <···················@pecos.ads.com>, Clinton Hyde writes:
> (uh oh, the flamethrowers are heating up already)

(with-torch-on (:> T)

> ;;BTW, the value of an association in an alist is usually retrieved with
> ;;CDR since the alist usually consists of dotted pairs.
> 
> i don't think i have EVER used dotted pairs in an a-list. 

Too bad.
>		suppose the
> second part was a list? you can't make a dotted pair with one that
> way. 

Hmm, funny thing about the "old style" of teaching lisp.  I thought a
list WAS a dotted pair.  I even thought the "tricky" part was printing a
list so as NOT to print the dot, rather than the other way around. Silly
me!

Whats a dotted pair?
  (cons 'a 'b)       -> (a . b)
  (cons 'a '(b c d)) -> (a b c d)

  (cdr '(a . b))     -> b
  (cdr '(a b c d))   -> (b c d)

In general,
  (car (cons <anything1> <anything2>)) -> <anything1>
  (cdr (cons <anything1> <anything2>)) -> <anything2>
No problem!

[There _are_ circumstances where you dont want to allow the cdr to be an
atom. Eg, collecting info on different stuff.
  (push new-item (cdr (assoc this-stuff database)))

[which assumes this-stuff is already there, I know]
From: Jeff Berger
Subject: Re: Legal forms in SETF?
Date: 
Message-ID: <BERGER.92Jun19135932@pride.cs.uchicago.edu>
In article <···················@pecos.ads.com> ·····@pecos.ads.com (Clinton Hyde) writes:



   (uh oh, the flamethrowers are heating up already)

   ;;BTW, the value of an association in an alist is usually retrieved with
   ;;CDR since the alist usually consists of dotted pairs.

   i don't think i have EVER used dotted pairs in an a-list. suppose the
   second part was a list? you can't make a dotted pair with one that
   way. so assuming it IS a dotted pair could be wrong. safer, i think,
   to NOT make them dotted, then you don't have potential probs.

    -- clint
   --

   Clint Hyde                      "Give me a LispM or give me death!" -- jwz


In Common Lisp, the standard is to use a cons for each association.
From CLtL2, p 431:

  An a-list is a list of pairs (conses); each pair is an association. 
  The CAR of a pair is called the KEY, and the CDR is called the
  DATUM.

In fact other functions are provided which assume this sort of
structure--e.g., PAIRLIS, RASSOC.

Of course, if the CDR of a pair is an atom, the pair will print as a
dotted pair. 

-Jeff Berger

--
Jeff Berger			|USmail:	Ryerson 256
······@cs.uchicago.edu	        |		Artificial Intelligence Lab
PH: (312) 702-8584		|		1100 East 58th Street
FX: (312) 702-8487              |               Chicago, IL  60637
From: Clinton Hyde
Subject: Re: Legal forms in SETF?
Date: 
Message-ID: <CHYDE.92Jun22111907@pecos.ads.com>
(with-singed-hairs-all-over 
  (apologize-profusely-for-being-a-poor-writer 'clint))

a-lists:

it's mostly a matter of consistency, i guess. i've consistently used
them with the CDR being a list, seldom (never?) an atom. if you are
consistently expecting a list, and do list-ops on it, and it's an atom
some time, ERROR. i'd rather not have errors like that. 

actually, i don't do alists all that often, so i've not made the
effort to be aware of the special fns that others mentioned. my loss,
i guess. i should go read CLtL2 all the way through...

 -- clint
--

Clint Hyde                      "Give me a LispM or give me death!" -- jwz

Advanced Decision Systems	Internet:  ·····@chesapeake.ads.com
2111 Wilson Blvd #800
Arlington, VA 22201		(703) 875-0327