CommonLispSpecialFormsauthor:JonLWhitefiles:[Eris]...Library>--CMLSPECIALFORMSdocumentation:CMLSPECIALFORMS.tedit/presscreated:13-Jan-84byJonLmodified:5-Oct-84,14-Nov-84,and18-Dec-84byJonLMacrosareprovidedforthefollowingCommonLispconstructs(so-called"specialforms"):LET,LET*,PROG*,PSETQ,PROGV,LIST*,DEFUN,CATCH,THROW,*CATCH,*THROW,andUNWINDPROTECT.Additionally,forefficiencyintheinterpreter,therearefunctionaldefinitionsforCATCH,THROW,andLIST*.Insofaraspossible,thesyntaxoftheseconstructsfollowsthatdescribedinthereferencemanual"CommonLisp:TheLanguage",publishedin1984byDigitalPress.LETisanalternativetoLAMBDA,whichputsthebindings"upfront"likePROGdoes;e.g.,(LET((X(MUMBLE))(Y(GRUMBLE)))(DO.FIRST.THING)(DO.LAST.THING))expandsinto((LAMBDA(XY)(DO.FIRST.THING)(DO.LAST.THING))(MUMBLE)(GRUMBLE))LET*issimilar,butthebindingshappensequentiallyratherthaninparallel.E.g.(LET*((X(MUMBLE))(Y(GRUMBLE)))(DO.FIRST.THING)(DO.LAST.THING))expandsinto((LAMBDA(X)(LAMBDA(Y)(DO.FIRST.THING)(DO.LAST.THING))(GRUMBLE))(MUMBLE))PROG*isthesimilarextensiontoPROG,namelythebindingshappen"sequentially"ratherthaninparallel.Likewise,PSETQisa"parallelSETQ",usingtheCommonLispsyntaxwhichpermitsnumerousassignmentstoappearinone"call"toPSETQ:(PSETQA(MUMBLEX)BA)willassigntoAthevalueof(MUMBLEX)andassigntoBthevaluewhichAhasbeforethecalltoPSETQ.PROGVprovidesameansforlambda-bindingalistofvariables:(PROGV......)islikePROGNexceptthatthefirsttwoitemsinthe"arglist"areevaluatedtoobtainalistofvariablenamesandalistofvalues;thenthevariablesarebound(asSPECVARS)tothecorrespondingvalues,andtheformsinthebodyexecuted,withthevalueofthelastonebeingthereturnvalueofthePROGV.ThisfunctionsexistsprimarilyasanaidinwritingLisp-likeinterpretersinLisp. q?` p` q?` g_p` b5q` b5 ` ` _")._ ^- ^- \\ [}#&3[} Z% .Z% Xn X WuZ #'Y/2D6wWu V V T T Sm'#&n.48 B%B%Sm R 1"O&+1m7N=/CHHR PP Oed 'Y(0 37N @CFlFlOe N E & 039?CHIIN L yZE &). 7N>B9JJL K] y%*. 7N?B9FlHHK] JJ H H GU PZ n%*.2D9=/CGCGCGU E'1;E D ynED CM y P' CM A y P'nA @ y P'n@ ?E?E = y= < y P'Z1"O#&< ;= y P'Z1"O#&#;= 9 y P'd9 8 y P' ;8 75';&,c 7N=/AbCC75 5Z1d;5 4 yE4 3- y P' 3- 1 y P'n1 0} y P'n0} /%/% - yd;- ,u y P'Z1,u + y P'Z1d;))+ ) y P'Z1d;)) (m y P'Z1 (m ' y P'd' % % $e#&+1m4FlFl# !;"O(0-:3; EHH! ]Z#$% ]  y P1  y P'Z1d U'; #&),c/58%9=/B9GCHHU  P1E#&   M;E -:.35 >M  yZ  $  y P'1 n E y#&(0+036w>B9JJE  yZ;"O'Y*,c039>AbII  PZ # /6w9=/B9DHH ='#&%)-:058>CFlII= E#&+.036w=/EE dn 5 5  q?` 2LIST*issimilartoLISTexceptthatthelastargumentisthefinalCDRoftheresultantlistratherthanthelastelement:(LIST'A'B'C)->(ABC)(LIST*'A'B'C)->(AB.C)DEFUNis,atfirstglance,analternativesyntaxforDEFINEQ:(DEFUNFOO(XYZ)...)<==>(DEFINEQ(FOO(XYZ)...))(DEFUNBARN...)<==>(DEFINEQ(BAR(LAMBDAN...)))CommonLispdoesn'tquitepermitthenotionsofNLAMBDAs,butforcompatibilitywiththevariousLispdialectsfromwhichitsprang(e.g.,MacLisp),thefollowingextensionstoDEFUNhavebeenimplemented(DEFUNBAZFEXPR(L)...)<==>(DEFINEQ(BAZ(NLAMBDAL...))Alsotheforms(DEFUNBLEHMACRO(L)...)(DEFUN(BLEHMACRO)(L)...)aresomewhatequivalenttomakeingaMACROdefinitionforBLEH;thedifferencesarethat(1)itisa"computed"macro,andallthecodebodyisdefinedunderanewinternalname,and(2)theargumentpassedtothecodebodyviathelambdavariable[inthisexample,L]willhavethenameofthemacrocons'dontothefrontofwhatwouldbepassedtoInterlisp'scomputedmacro.ThereasonforthisvariationisthatMacLisp'smacrosreceiveasargumentthepointertotheconscellthatthemacroexpanderisworkingon,ratherthanjustthecdrofthatcell.Oneadditionalnon-standardformatisimplementedalso:(DEFUN(MUMBLEGRUMBLE)(...)...)willputthefunctionaldefinitionunderanewinternalname,andputapointertothatdefinitionastheGRUMBLEpropertyofthelitatomMUMBLE.[Whencompilingsuchaform,MacLisp(andothers)alsocompilethe"new,internal"name;butInterlispmaynotbeabletoexpressthisinafilepkgCOMSwithoutmoredevelopment.]CATCHprovidesareturnpointforanon-lexicallyinitiatedexitfromitsscope.Forexample(CATCH'SOMETAG)setsupadynamicscopingforthe"tag"SOMETAG,andifatanytimeduringtheexecutionofthereisacall(THROW'SOMETAG)thentheCATCHwillbeexitedwithasitsvalue;butifnosuchTHROWisexecuted,thenthenormalreturnvalueofwillbethevalueoftheCATCH.BothCATCHandTHROW"evaluatetheirarguments",butCATCHdoessoinawaythatthefirstargument,thetag,isavailableduringtheevaluationofthesecondargument.*CATCHand*THROWareprovidedasmacrosforcompatiblitywithMacLispandFranz.UNWINDPROTECTisverysimilartoRESETLST/RESETSAVE--(UNWINDPROTECT......)willevaluate,anduponexitwillexecutealltheremainingformsinthelist--theso-called"cleanupcode"."Exiting"alsomeansanabortingduetoRESET(orHARDRESET)oranyerror.Unfortunately,theInterlispRETFROMandRETTOdonotcurrentlyexecutetheresetsaveformsunderaresetlstwhenretfrom'ingaframehigherinthestackthantheonewiththeresetlstinit;thishastheeffectthataTHROWtoaframehigherthananUNWINDPROTECTwillcurrentlynotactuallydoitscleanupforms.CAVEAT:CommonLispislexicallyscoped;butInterlispdoesn'tprovideamechanismcapableoffullyimplemetingthelexicalscopinginherentinPROGV,CATCH,andUNWINDPROTECT.SoonemustbepreparedforthesortoflimitationsonsuchcodingthatisencounteredwithERSETQinInterlisp. g,q` h h b5;$),c08%:>CFlHHb5 ` P#'Y+334` _ y PZdE!x"O$_ ^- y P1; "O#&^- \ \ [}Z #& -:36w>[} Z% d !x%-:1m358%=/Z% X nE !x%-:1m8%9?X Wu%)/2D:>AbAbWu V E#(0/38;AbGCGCV TZ 'Y).37N AbT Sm E!x%-:1m8:?Sm R R P'P Oe "O#&#Oe N n#N L P  'Y). 7N:?CCL K] d!x#% .48%;>CGCIIK] Jd"O'Y*.1m8>AbDHHJ H'"O%)1m38%EHHE D!x%).1m6w>@GCJJD CM;!x%*+. 8% CHHCM A y A @ yZ -:1m :>@ ?E'  'Y,c.1m8>AbDFlFl?E =1d #&&-:47N:AbHHH= <dE"O)-:38%>B9GCGC< ;=Zd#&&),c039>@B9HH;= 9' $9 8 8 75 75 5;#&&(0 3CHH1 0} P; $),c.2D0} /% /% -'E#&'Y,c.2D8%;>@DII- ,u yn"O(0-:/ EHH(m '1 "O),c2D' % % $e ;n#&%58%8$e # y  %)059# !'#&&*.39=/@HH! ]'Y.456w>CHJJ ] dn )+.456w CFlFl Zn!x#'Y/6w9B9GCGC U;n &(0-:358>B9EHHU '#&&)/35:=/>CII ' n ),c36w9@Fl M M   E%,c/8%>EGCGC EZ *.4;CEEE  %&),c03:>AbEHH   $'Y 1m5;> GC = =   5 5  q?`:3 g,q`IhJjh b5 b5 ` ` _ _ ^- ^- \ \ [} [} Z% Z% X X Wu Wu V V T T Sm Sm R R q?`h~SNAIL ~SNAIL r lj//{ERIS}LIBRARY>CMLSPECIALFORMS.PRESS;1JONL.PA19-Dec-84 01:52:40