[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What *is* this total horse-shit?



    Date: 19 July 1981 23:17-EDT
    From: George J. Carrette <GJC at MIT-MC>
    Subject: What *is* this total horse-shit?
    To: BUG-LISP at MIT-MC

    (selectq x (y z)) ==>

    ((LAMBDA (|NumP..1|) 
       (SETQ |NumP..1| (MEMQ (TYPEP X) '(FIXNUM FLONUM)))
       (COND ((AND (NOT |NumP..1|) (EQ X Y)) Z)))
     NIL)

    Worse is (selectq x ((3 y) z)) ==>

    ((LAMBDA (|NumP..3|) 
       (SETQ |NumP..3| (MEMQ (TYPEP X) '(FIXNUM FLONUM)))
       (COND ((OR (AND |NumP..3| (= X 3)) (AND (NOT |NumP..3|) (EQ X Y))) Z)))
     NIL)

    [1] The code is broken, screwing lots of people. Please test these things.
    [2] Since when does maclisp support the use of EQ on FIXNUMs?
	SELECTQ is defined to use EQ is it not? If somebody wants a
	selector in maclisp to work on both atoms and numbers then
	they can define one to use EQUAL.

    -gjc
[1]  It sure is.  Perhaps rename this one to be SELECT?  Looks like a perfectly
good SELECT macro to me.

[2]  A brief quote from the LISPM manual:
A test may be any of:
  1) A symbol		If the key is EQ to the symbol, it matches
  2) A number		If the key is EQ to the nuimber, it matches.
			Only small numbers (fixnums) will work.
  3) A list		If the key is EQ to one of the elements of
			the list, then it matches.  The elements of
			the list should be symbols or fixnums.
  4) T or OTHERWISE	The symbols T and OTHERWISE are special keywords
			which match anything.  Either symbol may be used,
			it makes no differnce; T is mainly for
			compatibility with MacLisp's CASEQ construct.
			To be useful, this should be the last clause in
			the SELECTQ.

Note two things:  First, SELECTQ isn't defined to use EQ blindly, it is
defined by type on a case by case basis.  FLONUMS aren't even legal,
JONL!  Second, the comparison 'EQ' when applied to fixnums on the LISPM
has the exact behaviour of the comparison '=' applied to fixnums in
MAcLisp.  I therefore submit that the use of '=' in MacLisp's is THE
correct way to translate the LISPM construct 'SELECTQ' to MacLisp.

George, consider, if you will, that you are proposing that fixnums be
BANNED in MacLisp's version of SELECTQ on the grounds that MacLisp
doesn't support the use of EQ on them ("Since when does maclisp support
the use of EQ on FIXNUMs?").  Since this then removes the incompatibility
between CASEQ and SELECTQ in MacLisp, we can just make SELECTQ turn into
CASEQ and save ourselves a lot of effort.  And if someone wants to run his
LISPM code in MacLisp, he can save himself the effort too.

(You might also note that if you depend on the LISPM manual for your MacLisp
definitions of things, George, that CASEQ as described would also use EQ and
forbid the use of FIXNUMS!)