zboot.lsp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. (DM !* (!#X) NIL)
  2. (SETQ !*EOLINSTRINGOK T)
  3. (!*
  4. "Needed for PSL, to avoid error messages while reading strings which
  5. contain carriage returns.")
  6. (!*
  7. "*( X:any ): NIL MACRO
  8. ===> NIL
  9. For comments--doesn't evaluate anything. Returns NIL.
  10. Note: expressions starting with * which are read by the
  11. lisp scanner must obey all the normal syntax rules.")
  12. (!*
  13. " ZBOOT -- Bootstrapping functions and SLISP extensions
  14. ONEP (U) EXPR used where?
  15. LIST2 (U V) EXPR compiler support fn
  16. LIST3 (U V W) EXPR compiler support fn
  17. LIST4 (U V W X) EXPR compiler support fn
  18. LIST5 (U V W X Y) EXPR compiler support fn
  19. MAPOBL (!*PI!*) EXPR UTAH random utility
  20. REVERSIP (U) EXPR UTAH support fn
  21. WARNING (U) EXPR UTAH support fn
  22. IMSSS additions: (complement LOSE mechanism)
  23. CDEF (FDSCR TYPE) EXPR conditional function definition
  24. CDE (Z) FEXPR conditional expr definition
  25. CDF (Z) FEXPR conditional fexpr definition
  26. CDM (Z) FEXPR conditional macro definition
  27. CLAP( LAPCODE ) FEXPR conditional lap definition
  28. C-SETQ (#ARGS) FEXPR conditional setq
  29. These are for compatibility with the IBM interpreter:
  30. ERASE( #FILE: file descriptor ):NIL EXPR
  31. ")
  32. (!* "ARE THESE USED ONLY IN COMPILER PACKAGE?")
  33. (!* (REMFLAG '(LIST2 LIST3 LIST4 LIST5 REVERSIP) 'LOSE))
  34. (!* (GLOBAL '(OBLIST)))
  35. (!* "IMSSS additions: ")
  36. (!*
  37. "CDEF( FNDSCR: pair, TYPE: {expr,fexpr,macro} ): {id,NIL} EXPR
  38. ----
  39. Conditional function definition.
  40. #FNDSCR = (NAME ARGS BODY) #TYPE = {EXPR, FEXPR, or MACRO}
  41. If the function is already defined, a warning is printed,
  42. the function is not redefined, and nil is returned.
  43. Otherwise, the function is defined and the name is returned.
  44. CDEF is called by CDE, CDM and CDF, analogs to DE, DF and DM.")
  45. (!*
  46. (DE CDEF (!#FDSCR !#TYPE)
  47. (PROG (!#NAME !#NEWARGS !#NEWBODY !#OLDDEF)
  48. (COND ((ATOM !#FDSCR) (RETURN (WARNING "Bad arg to CDEF."))))
  49. (SETQ !#NAME (CAR !#FDSCR))
  50. (COND ((NOT (EQUAL (LENGTH !#FDSCR) 3))
  51. (RETURN (WARNING (LIST "Bad args to CDEF for " !#NAME)))))
  52. (SETQ !#NEWARGS (CADR !#FDSCR))
  53. (SETQ !#NEWBODY (CADDR !#FDSCR))
  54. (COND ((NULL (SETQ !#OLDDEF (GETD !#NAME)))
  55. (RETURN (PUTD !#NAME !#TYPE (LIST 'LAMBDA !#NEWARGS !#NEWBODY))))
  56. ((PAIRP (CDR !#OLDDEF))
  57. (WARNING
  58. (LIST !#NAME
  59. " already "
  60. (LENGTH (CADDR !#OLDDEF))
  61. "-arg "
  62. (CAR !#OLDDEF)
  63. ", not redefined as "
  64. (LENGTH !#NEWARGS)
  65. "-arg "
  66. !#TYPE)))
  67. (T (WARNING
  68. (LIST !#NAME
  69. " is a compiled "
  70. (CAR !#OLDDEF)
  71. ", not redefined as "
  72. (LENGTH !#NEWARGS)
  73. "-arg "
  74. !#TYPE))))))
  75. (DF CDE (!#Z) (CDEF !#Z 'EXPR))
  76. (DF CDF (!#Z) (CDEF !#Z 'FEXPR))
  77. (DF CDM (!#Z) (CDEF !#Z 'MACRO))
  78. (!*
  79. "CLAP( LAPCODE ): {id,NIL} EXPR
  80. ----
  81. Conditional lap definition.
  82. If the function already has a compiled definition, warning is given,
  83. the function is not redefined, and nil is returned.
  84. Otherwise, LAP is called.")
  85. (DE CLAP (LAP!#CODE)
  86. (PROG (!#ENTRY !#ID OLD!#DEF)
  87. (COND ((NULL (SETQ !#ENTRY (ASSOC '!*ENTRY LAP!#CODE)))
  88. (RETURN (WARNING "CLAP: No *ENTRY in lap code."))))
  89. (SETQ !#ID (CADR !#ENTRY))
  90. (SETQ OLD!#DEF (GETD !#ID))
  91. (COND ((OR (NULL OLD!#DEF) (PAIRP (CDR OLD!#DEF))) (LAP LAP!#CODE))
  92. (T (WARNING
  93. (LIST !#ID
  94. " is compiled "
  95. (CAR OLD!#DEF)
  96. ", not changed to compiled "
  97. (CADDR !#ENTRY)
  98. "."))))))
  99. )
  100. (DM CDE (!#X) (CONS 'DE (CDR !#X)))
  101. (DM CDF (!#X) (CONS 'DF (CDR !#X)))
  102. (DM CDM (!#X) (CONS 'DM (CDR !#X)))
  103. (!*
  104. "C-SETQ( ARGS: (id any)): any FEXPR
  105. ------
  106. Conditional SETQ.
  107. If the cadr of #ARGS is already defined, it is not reset and its old
  108. value is returned. Otherwise, it acts like SETQ. ")
  109. (DF C!-SETQ (!#ARGS)
  110. (COND ((PAIRP (ERRORSET (CAR !#ARGS) NIL NIL)) (EVAL (CAR !#ARGS)))
  111. (T (SET (CAR !#ARGS) (EVAL (CADR !#ARGS))))))
  112. (!* "This CDE is best left here to avoid bootstrapping problems.")
  113. (CDE WARNING (!#X!#)
  114. (PROG (!#CHAN!#)
  115. (SETQ !#CHAN!# (WRS NIL))
  116. (TERPRI)
  117. (PRIN2 "*** ")
  118. (COND ((ATOM !#X!#) (PRIN2 !#X!#)) (T (MAPC !#X!# (FUNCTION PRIN2))))
  119. (TERPRI)
  120. (WRS !#CHAN!#)))
  121. (!*
  122. (CDE ONEP (U) (OR (EQUAL U 1) (EQUAL U 1.0)))
  123. (CDE LIST2 (U V) (CONS U (CONS V NIL)))
  124. (CDE LIST3 (U V W) (CONS U (CONS V (CONS W NIL))))
  125. (CDE LIST4 (U V W X) (CONS U (CONS V (CONS W (CONS X NIL)))))
  126. (CDE LIST5 (U V W X Y) (CONS U (CONS V (CONS W (CONS X (CONS Y NIL))))))
  127. )
  128. (!*
  129. "This definition of MAPOBL doesn't work in PSL, because the oblist has
  130. a different structure. MAPOBL is defined in the interpreter though.")
  131. (!*(CDE MAPOBL
  132. (!*PI!*)
  133. (FOREACH X IN OBLIST DO (FOREACH Y IN X DO (APPLY !*PI!* (LIST Y))))))
  134. (!*
  135. (CDE REVERSIP (U)
  136. (PROG (X Y)
  137. (WHILE U (PROGN (SETQ X (CDR U)) (SETQ Y (RPLACD U Y)) (SETQ U X)))
  138. (RETURN Y)))
  139. )
  140. (!*
  141. "ERASE( #FILE: file descriptor ):NIL EXPR
  142. -----
  143. This is defined in the IBM interpreter to (irrevocably) delete
  144. a file from the file system, which is a highly necessary operation
  145. when you are not allowed versions of files.
  146. It should be a no-op in the TENEX interpreters until such an
  147. operation seems necessary. This assumes the user will delete and
  148. expunge old versions from the exec.")
  149. (CDE ERASE (!#FILE) NIL)