N O T I C E This Document Has Been Reproduced From
Total Page:16
File Type:pdf, Size:1020Kb
N O T I C E THIS DOCUMENT HAS BEEN REPRODUCED FROM MICROFICHE. ALTHOUGH IT IS RECOGNIZED THAT CERTAIN PORTIONS ARE ILLEGIBLE, IT IS BEING RELEASED IN THE INTEREST OF MAKING AVAILABLE AS MUCH INFORMATION AS POSSIBLE to LABORATORY FOR MASSACHUSETTS INSTITUTE OF COMPUTER SCIENCE TECHNOLOGY MIT/LCS/TM-203 N81-29802 (N ASA -CR-11 64uo7) MALLISP LvII-N.;WNS 72 1; (tidssaci► usetts 111st. of Tech.) dC AJ4/M,F AU1 CSCL 09J (Inciab GI/u1 21171 MACLiSP EXTENSIONS Alan Bawden "Y Glenn S. Burke Carl W. Hoffman iR. r' D DEN'' R. 00 1 -N'O' I OW] '0 - Suly 1981 545 TECHNOLOGY SQUARE, CAMBRIDGE, MASSACI-1-JSETTS 02139 0 MIT/LCS/TM-203 MACLISP EXTENSIONS Alan Bawden Glenn S. Burke Carl W. Hoffman July 1981 Support for this research was provided in part by National Institutes of Health grant number 1 POI LM 03374-03 from the National Library of Medicine, the Advanced Research Projects Agency of the Department of Defense under Office of Naval Research contract numbers NG0014 -75-C- s 0661 and N00014-77-C-0641, the National Aeronautics and Spa e Administration under grant NSG 1323, the U.S. Department of Energy under grant ET- 78-C-02-4687, and the U.S. Air Force under Vp tCo'P(NAC`C fix= r49620-79-C-020. Madisp Extensions July 1981 Alan Bawden Glenn S. Barks Carl W. Hoffman This report describes research done at the laboratory for Computer Science of the Massachusetts Institute of Technology. Support for this research was, provided in part by National Institutes of Health grant number 1 P01 LM 03374-03 from the National Library of Medicine, the Advanced Research Projects Agency of the Dei; ^rtment of Defense under Office of Naval Research Contract numbers N00014.75-C-0661 and N000.14-77-C-0641, the National Aeronautics and Space Administration under grant NSG 1323, the U. S. Department of Energy under grant Vl'-78-C-02- 4687, and the U. S. Air Force under grant' F49620-79-C-020. MASSACHUSETTS INSTITUTE OF 'ITRCHNOLOGY LABORATORY FOIL COMPUTER SCIENCE CAM131U GF. MASSACIIUSFATS 02139 a Abstract This document describes a common subset of selected facilities available in Maclisp and its derivatives: Pi)P-10 and Muitics Maclisp, Lisp Machine Lisp (letalisp), and NIL. The object of this document is to aid people in writing code which can run compatibly in more than one of these environmeats. AcknowkfgeineNs Much of the documentation presented here is drawn from pre-existing sources and modified to be presentable in this context. The documentation on sharpsign is derived from that written by Richard S. Lamson as a Multics online help segment. The descriptions of backquote and defstruct are derived from existing online documentation. The documentation on format shares some portions with the Lisp Machine Manual; text has been exchanged in both directions. The description of defmacro also draws heavily on the existing documentation in the Lisp Machine Manual. 1'he lisp Machine Manual is authored by 'Daniel Weinreb and David Moon, and the format documentation therein was contributed to greatly by Guy Steele; they have all thus indirectly contributed a great deal to this paper, as have innumerable others who aided in the preparation of the Lisp Machine Manual. We would like to thank Joel Moscs for providing the motivation to bring Lisp up-to-date on Multics, and Peter Srolovits, under whose auspices this document was produced. Note Any comments, suggestions, or criticisms will be welcomed. Please send Arpa network mail to MACLISP-EX'I'T NSIONSGMIT-ML. Those not on the Arpanet may send U.S. mail to Glenn S. Burke Laboratory for Computer Science 545'I'echnology Square Cambridge, Mass. 02139 0 Copyright by the Massachusetts instiuite of 'Technology; Cambridge, Mass, 02139 All riots rewrved. Maclisp Extension% Table of Contents Table0^^^N^^ ~°N^^^»mmmm^Nm^^ of lLIntroduction , , ~ . .^ , , ^ ^ ^^^ ~ ^ ^ ^ ' ` ^ ' ^ ` ^ ` ^ ' ' ^ ` ^ ^ ^ ` ^ ' ` ' ^ ^ ^ ` ^ I 1 ^ 1 Compatibility ,^,' , , , ^ ... , . ,., , , , , ^ , , . ~ ° . ° .. ~. & 1 ^2 Conventions , , . ' ' ' ^ ^ ^ ^ ^ ' ^ , , ^ ' ^ , ^ . ^ . , ~ , . ^ , . ^ , , . - , ~ . & ]L Backquote , ,'. ~..^ ° , , .`.. ^ ^ ' ^ ^' ^ ^ ' ^ ' ' ^ ' ' ' ' ^ ' ^ ^ ' ' ^ ^' ' ^ ^ ^ 2 ]L Sharpsign , , ^ , . .. ^ . ^ . .^^ ^ ` ' ' ' ^^ ` ' ' ` ^ ~ ` ` ' ' ^ ' ^ ^ ' ' ^ ' ' ^ ' ` ° 5 4, E*tmmdedDeffin . .^ . , . ,'^ , ` , , . ' ' ^ ' . ^ ^ ^ ^ , ^ ' ^ ^ ^ ^ ' ' , , ^ ' ` ' ^ 8 5iI)wftmmnmN . , , .. .. , . - ,. ^ ^ ~ ,. ° . ~ , . , , . , . - . ~ . ^ . .mN &i Other Definition Facilities. , . ° " , . ^ , ^ ^ . , . ^ . ^ . , - . ^ . , . , , . ^13 7. SekE ^ ^ . , , . - . ^ . ^ ^ . , ^ ` ' ' ' ' ' ' ` ^ ^ ^ ' ` ° ` ` ` ^ ' ' ^ ^ ` ^ ^ ^ ^ ^ ` 15 0[ New Functions and Special Forms . , , . ^ ` ' , . ~ . , . , , . , , ^ . .17 8.8 Bit Hacking ° . ' - . , ° ^ ^ . ^ ~ . ^ , - . , . , . ,K7 8.8.1 Boolean Operations ^ . ^ . , . ^ . , . ' . , . , , . ^ . .17 8.1.2 Byte Manipulation . , ^ . ^ - . ^ . , . ^ . ' . ~ ^ . , , ,uw 8.1.3 Testing . , . , . , . , ^ . ^ . ^ ^ . , , . ' . - .&s 8.2 Predicates . , ^ . ' . ' ' ^ ~ . ' ^ ' ` ' ` ' ' ` ' ` ' ^ ' ` ' ^ - ^ ' ^ ^ ' ^ ^ ' -18 8.3 Lists , , . , , . ^ ' ' ^ ' . ' ' ' ` - ' ^ ' ' ' ' ^ ^ ' ' ^ ' ^ ' ^ ' ~ ' ' ' ' '»9 8.4 Vmrimblmm. ^ ~ . ^ . , ° ^ ^ ' . , . , , . ' . , , . , , ^ ^ . ^ . ^20 8.5 Flow wfControl , . ~ . ^ . , . ~ , . ^ . , , . .2X 0.5.1 Conditionals . , . , , . " , , . - , . ^ . , , . , . , . .2u 8.5.2 SeL—cdon . , . , . ' . ' . ' ^ . ^ ` ^ - ' ' ' ^ ^ ' ' ' ' ` ' ' ' ' ' ' ' - ^ ` '22 8,5L1^ Itmrmtiom. , ' . ^ . , . ^ ^ ^ . , . ^ ^ . ^ ~ . ^ . , . , . , . .23 8.5,4 Nmn'&oc*30xits ^ . , . , . , ' . ^ . ' ^ . , . , , , , . ^ ,2w 8,6 Miscellaneous . , ^ . , . , . , . ^ . , ^ ` ^ . ~ , ^ . ^ ^ . ^ . ^ ^ . 25 §L Delstruct. , ^ . ^ ^ . , , . - , , ' . , , . , ~ , . , . , . ° . .@6 9\1 Kntmwdu*Kior . , . ^ . , ,^, _ ^ . , , ^ ^ . , , , , . , , . _ . , . ,26 9.2 /kSimple F.xample , . , . , . , , . , . ^ . , . , ^ , , . , , . , , ^ ,26 9.3 Syntax of defstruct . , . ' , . , . ' . ' ^ ' ' ^ ' ` , - ' ' . - ' ' ^ ' ' ^ ` ` '27 9.4 Options tmdefstroCt. , . ' ~ ' ' ` ' ' ' ' ' ' ' ^ ' ' ° ` ^ ` ' ' ^ ` ` - ^ ` ^28 9,4.1^.^ pm, , . ' ^ . ^ . ' ^ ' ' ' ' ' ' ' ` ' ' ^ ^ ^ ` ' ^ ` ' ` ' ^ ^ 20, 9.4.2rm.2 mmnmt pto ^ . .. , . ' , . , . ^ . , ^ , , , . , , , . ^ , , , , , 30 9,4.3 mltmnmnt . ^ ^ . , ^ . ` . ^ . ^ . ^ . .3& 9*4 dm . , ^ . ' ' ' . ' ^ . ' ' ° ` ' ^ ' ' ' ' ^ ^ ^ ' ' ' ' ' ' ` ' ' ' ' ' ` - '»2 9*5 cmmc-narne . , ^ , . , . ^ , . ^ ^ ^ . ^ ^ . , . ,D3 9.4.6 include . ^ . ^ . , , . , ^ ^ . ^ . .DD 9,4.7 nammd. ^ . , . , . _ . , . ^ . ^ , . .35 ^49A.8 makc-array . ^ . , . , ' ' . ^ . , . ^ . ^ . .35 9,4.9 xfa'fumnctiom . ' , ^ ^ . _ . ^ ' ^ . .35 9.4,10^^ ofa'mmnmc. ' . , . ^ ^ . 36 9.4-11.11 r*tcrma-ptr, . ^ . ^ . ^ ^ ` . ' . ^ . 36 ` ^4 12 nnhm\. ^ . ` ` . ^ ^ . , ^ ^ ' ^ ^ ^ . .36 9.4.13 $hz.c-macro . , . .36 9,4.14 hidzd-offset . , . " . ` . ^ . , . ^ . ' . .3h 2l'J[1I/0\ ^ I'ablemf Contents Maclisp Extensions ^ 9.4.15 but-first. , . , , ^ . ^ . ° , ^ ' , , ^ ^ , , . , , , , , . , , . ^ ^ , . 37 9.4.16 ,^, ' . ^ ,^^^ ^ ^^ `'^ ^ ' ^ '^ ^ ^ `'' ^ ^^^^ °^^ ^^` 37 ^ 9A.17 ewal-when . , , , - ^ , . , . , ~ , , . ~ , ^ ~ ^ ' ^ ° ^ ^ ' ' ^ ^ - ` ` ^ ^ ` ^ ^ ` ^ 37 ^ 9.4.08 property ^ , ^ . , . ,` . ~ ^ . ^ . ^ , , . , ^ , , ^ , , , , , , , , , ^ , ° , , 38 ^ 9A_19 A Tv^^^^^^N^^^^^^^^. , ^ , ^ ^ , . ^ ^ ^ ` ^ , ^ ^ ^ ' " ` ` ' ^ ^ ^ ^ ^ ' ' 38 ' - ' ^ ^^^0Other Options . , , ^ . , ,.. ^ , , ^ ' ' ^ ^ , ^ ^ ` ` ^ ^ ~ ^ ' ^ ^ ° ' ^ ° ` ^^ r 9.5 ll_.pu-^F^^^. , , , . , , ° . ^ . , . , ° , . , . , . , , ~ , , , ~ . , ~ ~ ~ ` , ^ ' - ^ 38 9.6 ANoxt_-_-^-_ ~ . , _' , ^ . , . ^ . , , ^ , ` ^ . ' , ~ , ^ ' ' , ° ~ ^ ^ ` . ^ ^ ` 40 ^ 9JThe Structure - . , , . , ^ , . - ^ , . ^ ^ . ^ ^ . , , . ^ , , , ^ , 41 ^ 9j8 Bkmn$iommtodeKstrxct , . , , . , . , . , , , . ~ ° , ^ , ~ ~ . , . , , . , , , . , , 42 9,8.1 A Simple Example . , . , , , . , . , . - ^ , . , . , , ^ . , ^ ^ ^ ^ , , , ' ' ' 42 9.8.2 Syntax of . , . - . ^ , , , ^ ' ' ' . ` , ' ^ ' ~ . ' ^ ' ` ^ ^ ^ ^ 43 9.8.3 Options to , .'. , ~ . ^ . ^ ^ . ' , . ^ ^ ° ^ ^ ^ , ^ ' , ^ ^ ^ ^ 43 9.8.3.1 cons . , , . ~ . , . ~ . ' . , , . , - , , ^ ^ ^ . ^ ^ ^ ^ ^ ' . , , ^ ^ . ^ 43 9.8.3.2 ref . , . - , . , , . ° . ^ ^ ^ , ^ , ^ ^ . , ° . , . , ° . , . , , ° ^ , ^ 44 9.8.3.3 overhead , , . ^ . , , . , . , . , , . , , . , . ^ , . , ^ , ' ^ ^ ^ ^ ^ ^ ` , , ° 45 9.8.3.4 named , . , . , . , , , . , ^ , . , ~ . ^ ^ , ^ ^ . ^ , ^ , , ~ , . , , , , ~ 45 9.0.3.5 keywords , . , , . , . ~ , ^ ^ ` , ` ^ ^ ` ' - . ^ ' ^ ' ` , ` ^ ^ ` ` ` ^ . ^ ^ 45 10.Fortimwt. , - , , . , , . , . ° . , . ^ , . , ~ ^ ^ , , . ' ^ . ^ , ~ 47 10,1 The OperMors ^ , ^. , ^. ^, .. , ..,. ^ ° , ^ . ., , ^.~ ^ ,^ ^^ ^.~ ^^ . 40 20.2 Other Entries ^ . ... ,'. ^ . ,.^^. , . .,,^ ' , `^^ ^ ^^^~ .`^. .^ 54 10i3 Defining your own ,^ ' . ~ ° ,^ ' . ' ' ^^ '^ ^ ^ ' ' '^ ^ ' `'^ ` ^` ^ ' ^`' ^`^ 54 t0AU-ormmmkand Strings. , . , ° , . , , . , , , . , . ^ , . - , . , , ` ~ ^ ^ ~ ^ 57 8X. System Differences , . , . , . - . , . , . , . S8 11,1 PDP-10, ^ . ^ . , , ^ - , ^ , ^ ^ . ^ . ^ , . , ^ . , , . ^ . ^ , , , ~ ^ ^ . , 59 11.1.1 WhermTmF^dK^, . , . ... ... ^ .. ^ ,.^ . .. , ,, ' ., , 58 11. 1.2 '11fing«To Watch Out Fon. .,, ^ ' .. ... , . .., . ^ . ^ ,-., ^ . 59 1 .1.13 I^wnthenDocwmmentation. , . .. , ^ ^ . , . ^ , , . , . ~ . ^ . ^ , 59 13 .7,NNultics , . , , , ' ^ ^ ° ^ ' ^ , ' ` , ^ ' ' ^ ' ` , . ^ ^ ^ ^ ^ ' ^ ^ ^ ^ ^ ^ ^ ^ ' ^ , ' ' 59 1l^.&WNve^:^mF^dUk, . , . .. ^ .. , , , , . , , . ^ . , , - ^ 59 11 .2.2 'Ibing«'rw Watch Out For . ,,.. .`. ., ^ - ., ., . , ,.. ,,. ,. ~.,. 60 112.3 Fxmrt6cYDocumentation . , ^ . , , ^. ^ . ~ ,.