From: Antonis Karidas
Subject: MacLisp's sassq
Date: 
Message-ID: <857be997.0108161156.26501c58@posting.google.com>
Hi Lispers,

 Does anyone know ( remember ) any details about MacLisp's 'sassq'
primitive ? I came across this while looking at a very old piece of
code but I could not find anything in Cltl2's compatibility sections.
From the context, I suspect it is similar to 'assoc' but it takes an
extra argument of function type.

Thank you in advance,
Antonis

From: Christopher J. Vogt
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <3B7C2931.ECEC4D1A@computer.org>
Antonis Karidas wrote:
> 
> Hi Lispers,
> 
>  Does anyone know ( remember ) any details about MacLisp's 'sassq'
> primitive ? I came across this while looking at a very old piece of
> code but I could not find anything in Cltl2's compatibility sections.
> From the context, I suspect it is similar to 'assoc' but it takes an
> extra argument of function type.

This sounds like sassoc (did you maybe mis-spell?).  The third aregument fo
sassoc is a function of no arguments whose value is returned if the assoc fails
e.g.
(sassoc 0 '((1 . one) (2 . two)) #'(lambda () 'fail)) 
FAIL
From: Bob Riemenschneider
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <tpr8ubsogk.fsf@coyote.csl.sri.com>
"Christopher J. Vogt" <····@computer.org> writes:

> Antonis Karidas wrote:
> > 
> > Hi Lispers,
> > 
> >  Does anyone know ( remember ) any details about MacLisp's 'sassq'
> > primitive ? I came across this while looking at a very old piece of
> > code but I could not find anything in Cltl2's compatibility sections.
> > From the context, I suspect it is similar to 'assoc' but it takes an
> > extra argument of function type.
> 
> This sounds like sassoc (did you maybe mis-spell?).  The third aregument fo
> sassoc is a function of no arguments whose value is returned if the assoc fails
> e.g.
> (sassoc 0 '((1 . one) (2 . two)) #'(lambda () 'fail)) 
> FAIL

Maclisp's SASSQ is like SASSOC, but uses EQ for comparison rather than
EQUAL.  Its definition is

   (defun sassq (x l f) 
      (or (assq x l) (funcall f)))

so I guess

   (defun sassq (x l f)
      (or (assoc x l :test #'eq) (funcall f)))

will do in CL.

						-- rar
From: Kent M Pitman
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <sfwpu9vbpqb.fsf@world.std.com>
Bob Riemenschneider <···@coyote.csl.sri.com> writes:

> 
> "Christopher J. Vogt" <····@computer.org> writes:
> 
> > Antonis Karidas wrote:
> > > 
> > > Hi Lispers,
> > > 
> > >  Does anyone know ( remember ) any details about MacLisp's 'sassq'
> > > primitive ? I came across this while looking at a very old piece of
> > > code but I could not find anything in Cltl2's compatibility sections.
> > > From the context, I suspect it is similar to 'assoc' but it takes an
> > > extra argument of function type.
> > 
> > This sounds like sassoc (did you maybe mis-spell?).  The third aregument fo
> > sassoc is a function of no arguments whose value is returned if the assoc fails
> > e.g.
> > (sassoc 0 '((1 . one) (2 . two)) #'(lambda () 'fail)) 
> > FAIL
> 
> Maclisp's SASSQ is like SASSOC, but uses EQ for comparison rather than
> EQUAL.  Its definition is
> 
>    (defun sassq (x l f) 
>       (or (assq x l) (funcall f)))
> 
> so I guess
> 
>    (defun sassq (x l f)
>       (or (assoc x l :test #'eq) (funcall f)))
> 
> will do in CL.
> 
> 						-- rar

Right.  And my Maclisp manual adds, about SASSOC:

 The reason that f does not receive an argument of the missing 
 object is for compatibility with the Lisp 1.5 dialect. As a
 result, this function is almost never used. Most people
 prefer to write simply:
  (OR (ASSOC object l) (FUNCALL f object))
From: Wolfhard Buß
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <m3vgjn4t0h.fsf@buss-14250.user.cis.dfn.de>
········@aias.gr (Antonis Karidas) writes:

> Hi Lispers,
> 
>  Does anyone know ( remember ) any details about MacLisp's 'sassq'
> primitive ? I came across this while looking at a very old piece of
> code but I could not find anything in Cltl2's compatibility sections.
> From the context, I suspect it is similar to 'assoc' but it takes an
> extra argument of function type.

How about

 (defun sassq (item a-list function)
   (or (assoc item a-list :test #'eq)
       (funcall function)))


-wb
From: Bob Riemenschneider
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <tplmkjsl6u.fsf@coyote.csl.sri.com>
·····@gmx.net (Wolfhard Bu�) writes:

> ········@aias.gr (Antonis Karidas) writes:
> 
> > Hi Lispers,
> > 
> >  Does anyone know ( remember ) any details about MacLisp's 'sassq'
> > primitive ? I came across this while looking at a very old piece of
> > code but I could not find anything in Cltl2's compatibility sections.
> > From the context, I suspect it is similar to 'assoc' but it takes an
> > extra argument of function type.
> 
> How about
> 
>  (defun sassq (item a-list function)
>    (or (assoc item a-list :test #'eq)
>        (funcall function)))

I'm glad Wolfhard responded, so I don't have to follow up on my own
posting.  :-)

There's actually some argument that the second disjunct should be

   (apply function nil)

rather than 

   (funcall function)

The former is used in the Moonual and Chine Nual, apparently so that
the "function" argument can be a special form or macro; the Pitmanual
has the latter.  (I got curious about the history.  BTW, the Chine
Nual's claim that SASSQ dates back to Lisp 1.5 seems to be wrong.  The
Lisp 1.5 manual mentions SASSOC, but not SASSQ.)  The odds of this
making a difference in dealing with some old code seem pretty long,
but ... .

						-- rar
From: Kalle Olavi Niemitalo
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <87d75sffqd.fsf@Astalo.y2000.kon.iki.fi>
Bob Riemenschneider <···@coyote.csl.sri.com> writes:

> There's actually some argument that the second disjunct should be
> 
>    (apply function nil)
> 
> rather than 
> 
>    (funcall function)
> 
> The former is used in the Moonual and Chine Nual, apparently so that
> the "function" argument can be a special form or macro; the Pitmanual
> has the latter.

Huh, does MacLisp allow calling special forms and macros with
APPLY?  What does it do with arguments?
From: Kent M Pitman
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <sfw1ym8ywdb.fsf@world.std.com>
Kalle Olavi Niemitalo <···@iki.fi> writes:

> Bob Riemenschneider <···@coyote.csl.sri.com> writes:
> 
> > There's actually some argument that the second disjunct should be
> > 
> >    (apply function nil)
> > 
> > rather than 
> > 
> >    (funcall function)
> > 
> > The former is used in the Moonual and Chine Nual, apparently so that
> > the "function" argument can be a special form or macro; the Pitmanual
> > has the latter.

Hmm.  I'll have to look into this.
 
> Huh, does MacLisp allow calling special forms and macros with
> APPLY?  What does it do with arguments?

Considerable discussion of this can be had in my 1980 Lisp Conference paper:
 http://world.std.com/~pitman/Papers/Special-Forms.html
If you care about the history, it's probably better to read that paper than
for me to clumsily try to recount it here.  The webbed version contains
both the original text and some annotations to help you understand the 
historical context.
From: Bob Riemenschneider
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <tp8zgesbu6.fsf@coyote.csl.sri.com>
Kalle Olavi Niemitalo <···@iki.fi> writes:

> Huh, does MacLisp allow calling special forms and macros with
> APPLY?  What does it do with arguments?

I have to take this back.  I seemed to remember that this was possible
in MacLisp, but I may well have been thinking of some other dialect.
The manual entries for APPLY certainly don't suggest that anything
other than a function is legal.

							-- rar
From: Kent M Pitman
Subject: Re: MacLisp's sassq
Date: 
Message-ID: <sfwu1z25u6m.fsf@world.std.com>
Bob Riemenschneider <···@coyote.csl.sri.com> writes:

> 
> Kalle Olavi Niemitalo <···@iki.fi> writes:
> 
> > Huh, does MacLisp allow calling special forms and macros with
> > APPLY?  What does it do with arguments?
> 
> I have to take this back.  I seemed to remember that this was possible
> in MacLisp, but I may well have been thinking of some other dialect.
> The manual entries for APPLY certainly don't suggest that anything
> other than a function is legal.

Oh, you definitely can APPLY a fexpr.  I think  you cannot APPLY a macro
(or are advised not to) since many were displacing and APPLY offers no
"&whole" form.  However, for a curious and extreme example of this, see
footnote 7 in http://world.std.com/~pitman/Papers/Special-Forms.html