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

BUG -- NOT



    HI! The following code sements are not identical, though according
    to GSteel's Lisp book (2nd ed) they should be:

page number?

    ;;;;;
    (sort lis 'test1)
    (sort lis 'test2)
    (some-function lis)
    ;;;;;
    (setq lis (sort lis 'test1))
    (setq lis (sort lis 'test2))
    (some-function lis)
    ;;;;;;

    I belive the top version leads to error: some parts of lis are left out.

Of course they are different.  SORT is defined to be
destructive [CLtL2, p.408], so you have to catch the output and setq lis.

    Also, the following code segments are not identical:
    (print '(lambda (x) (car x)) lis)
    ;;;;
    (print 'car lis)
    ;;;
    The lisp interpreter/compiler does not like the first one. I think if I put
    #' intead of ' it will accept it, but it should not be so. I thought the
    # symbol in this case was to allow for functions/values declared outside of the
    lambda body and used withing the lambda body.

??? PRINT's second arg should be a stream, not a list.  Thus, both of the
above code fragments should error.  Maybe you meant

 (print ((lambda (x) (car x)) lis)), which does behave equivalently to
 (print (car lis))

except that MCL might complain if lis is not declared free;
MCL by default compiles even s-exps you type at the interpreter.
If you do (defvar lis '(a b c)) first, the two above behave the same.

-- Bob