The Revised Maclisp ManualThe PitmanualPage C-6
Published by HyperMeta Inc.
Prev | Index | Next
Common Lisp Conversion
CL Conversion
Trivial Changes
Easy Changes
Hard Changes
Substandard Code
Cosmetic Changes
User-Defined Functions
Non-Portable Code

Conv: Cosmetic Changes

[Blue Marble]
Climate Change
Why is a polar bear like a canary?

Common Lisp provides a variable called MOST-POSITIVE-FIXNUM which holds the positive fixnum that has the greatest magnitude. The idiom (LSH -1 -1) was formerly popular in the Maclisp family (including Zetalisp) for determining this value. It should be replaced by the Common Lisp variable MOST-POSITIVE-FIXNUM.

    (LSH -1 -1)  becomes  MOST-POSITIVE-FIXNUM

Common Lisp defines that forms inside a toplevel PROGN will be compiled. In Maclisp (and Zetalisp), only PROGN forms which had the form (PROGN 'COMPILE ...) would get compiled. As a result, you may wish to Tags Search for (QUOTE COMPILE) and 'COMPILE and remove them where they occur uselessly at the head of a PROGN since they are no longer necessary.

    (PROGN 'COMPILE ...)         becomes  (PROGN ...)
    (PROGN (QUOTE COMPILE) ...)  becomes  (PROGN ...)

Common Lisp defines that symbols in the keyword package are self-evaluating. As such, there is no need to quote them. ':FOO or (QUOTE :FOO) may be written as simply :FOO in Common Lisp. This has been true for a while in Zetalisp as well, but some code may not have been converted and this may be a convenient time to do such conversion.

    ':xxx         becomes  :xxx
    (QUOTE :xxx)  becomes  :xxx

Common Lisp defines that #' may be used as an abbreviation for FUNCTION, in a manner analogous to the way that ' can be used as an abbreviation for QUOTE. This was true of Maclisp/Zetalisp but some old code may not use the convention and this may be a convenient time to bring old code up to date.

    (FUNCTION name)  becomes  #'name

Common Lisp allows symbols to be used as functions with APPLY, FUNCALL, etc. but symbols are not themselves functions. In some situations, it may be important to indirect through the symbol's name. For example, you might prefer to write (SETF (GET 'FOO 'HOOK-FUNCTION) 'FOO-HOOK) rather than (SETF (GET 'FOO 'HOOK-FUNCTION) #'FOO-HOOK) since if FOO-HOOK becomes redefined, you probably want FOO's HOOK-FUNCTION property to refer to the new definition. On the other hand, in situations where the function definition will have to be looked up directly every time, it is better not to have to indirect through the symbol. Hence, it is stylistically better—and frequently more efficient—to write (APPLY #'FOO ...) rather than (APPLY 'FOO ...).

    (FUNCALL 'fn ...)   becomes  (FUNCALL #'fn ...)
    (APPLY 'fn ...)     becomes  (APPLY #'fn ...)
    (MAPCAR 'fn ...)    becomes  (MAPCAR #'fn ...)
    (MAPCAN 'fn ...)    becomes  (MAPCAN #'fn ...)
    (MAPCON 'fn ...)    becomes  (MAPCON #'fn ...)
    (MAPC 'fn ...)      becomes  (MAPC #'fn ...)
    (MAPLIST 'fn ...)   becomes  (MAPLIST #'fn ...)
    (MAPL 'fn ...)      becomes  (MAPL #'fn ...)
    (SORT list 'fn)     becomes  (SORT list #'fn)

CL Conversion (1 2 3 4 5 (6) 7 8)

The Revised Maclisp Manual (Sunday Morning Edition)
Published Sunday, December 16, 2007 06:17am EST, and updated Sunday, July 6, 2008.
Prev | Index | Next