06-ids.lpt 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. PSL Manual 7 February 1983 Identifiers
  2. section 6.0 page 6.1
  3. CHAPTER 6 CHAPTER 6 CHAPTER 6
  4. IDENTIFIERS IDENTIFIERS IDENTIFIERS
  5. 6.1. Introduction . . . . . . . . . . . . . . . 6.1
  6. 6.2. Fields of Ids . . . . . . . . . . . . . . . 6.2
  7. 6.3. Identifiers and the Id-Hash-Table . . . . . . . . 6.2
  8. 6.3.1. Identifier Functions . . . . . . . . . . 6.3
  9. 6.3.2. Find. . . . . . . . . . . . . . . . 6.4
  10. 6.4. Property List Functions. . . . . . . . . . . . 6.5
  11. 6.4.1. Functions for Flagging Ids . . . . . . . . 6.6
  12. 6.4.2. Direct Access to the Property Cell. . . . . . 6.7
  13. 6.5. Value Cell Functions. . . . . . . . . . . . . 6.7
  14. 6.6. Package System Functions . . . . . . . . . . . 6.10
  15. 6.7. System Global Variables, Switches and Other "Hooks" . . 6.13
  16. 6.7.1. Introduction . . . . . . . . . . . . . 6.13
  17. 6.7.2. Setting Switches. . . . . . . . . . . . 6.14
  18. 6.7.3. Special Global Variables . . . . . . . . . 6.15
  19. 6.7.4. Special Put Indicators. . . . . . . . . . 6.15
  20. 6.7.5. Special Flag Indicators . . . . . . . . . 6.16
  21. 6.7.6. Displaying Information About Globals . . . . . 6.16
  22. 6.1. Introduction 6.1. Introduction 6.1. Introduction
  23. __________ __ __________ In PSL variables are called identifiers or ids. An identifier is
  24. implemented as a tagged data object (described in Chapter 4) containing a
  25. __ _____ pointer or offset into a five item structure - the id space. One item in
  26. this structure is called the print name, which is the external
  27. __ representation of the id.
  28. __ ____ _____ The interpreter uses an id hash table to get from the print name of an
  29. __________ __ _____ __ _____ __ ____ identifier to its entry in the id space. The id space and the id hash
  30. _____ table are described below.
  31. Sometimes there is a need for more than one name space when one is
  32. building a large system. For example, one may wish to allow several
  33. programmers to each produce a part of a system without having to worry
  34. about name conflicts. PSL provides a package system for this purpose,
  35. __ ____ _____ giving the user a tree-structured id hash table. Identifiers 7 February 1983 PSL Manual
  36. page 6.2 section 6.2
  37. 6.2. Fields of Ids 6.2. Fields of Ids 6.2. Fields of Ids
  38. __ ____ ____ ____ An id is an item with an info field; the info field is an offset into a
  39. __ _____ ____ special id space consisting of structures of 5 fields. The fields (items)
  40. are:
  41. _____ ____ ______ print-name The print name points at a string of characters which is the
  42. __________ external representation of the identifier. The syntax for
  43. __________ identifiers is described in Section 12.5 on reading
  44. functions.
  45. ________ ____ property-cell One may want to associate various flags and properties with
  46. __________ an identifier. These can be stored on a property-list for
  47. __ an id, flags by name and properties by an (indicator .
  48. __ value) pair. The property cell of an id contains a pointer
  49. to this list. Access is by means of functions defined in
  50. Section 6.4.
  51. _____ ____ __________ value-cell The value of the identifier or a pointer to the value in the
  52. heap is stored in this field. If no value exists, this cell
  53. __________ contains an unbound identifier indicator. These cells can
  54. be accessed by functions defined in this chapter.
  55. _____ _____ _____ macro ________ ____ ________ macro function-cell An id may have a function or macro associated with it.
  56. PutD GetD RemD PutD GetD RemD Access is by means of the PutD, GetD, and RemD functions
  57. defined in Section 10.1.2.
  58. _______ ____ package-cell PSL permits the use of a multiple package facility (multiple
  59. __ ____ _____ id hash table). The package cell refers to the appropriate
  60. __ ____ _____ id hash table.
  61. 6.3. Identifiers and the Id hash table 6.3. Identifiers and the Id hash table 6.3. Identifiers and the Id hash table
  62. __________ The method used by PSL to retrieve information about an identifier makes
  63. __ ____ _____ use of the id hash table (corresponding to the Oblist, or Object list, in
  64. __________ some versions of LISP). A hash function is applied to the identifier name
  65. __ ____ _____ giving a position in the id hash table. The contents of the hash table at
  66. __ _____ __________ that point contain an offset into the id space. For a new identifier, the
  67. __ _____ next free position in the id space is found and a pointer to it is placed
  68. in the hash table entry.
  69. __ The process of putting an id into the hash table is called interning.
  70. __ This is done automatically by the LISP reader, so any id typed in at the
  71. terminal is interned. Interning can also be done by the programmer using
  72. Intern Intern ______ __ __ the function Intern to convert a string to an id. An id may have an entry
  73. __ _____ in the id space without being interned. In fact it is possible to have
  74. __ several ids with the same print name, one interned and the others not.
  75. __ (The use of the package system allows one to have several interned ids with
  76. the same print name.)
  77. __ _____ Note that when one starts PSL, the id space already contains
  78. __ approximately 2000 ids. These include all of the ASCII characters, the
  79. functions and globals described in this manual, plus system functions and PSL Manual 7 February 1983 Identifiers
  80. section 6.3 page 6.3
  81. globals. If a user uses any of these names for his own functions or
  82. globals, there can be a conflict. This is another reason for having a
  83. package system. A warning message appears if a user tries to redefine a
  84. system function.
  85. ? Do you really want to redefine the system function 'name? (Y or N)
  86. If the user answers "Y", his definition replaces the current definition.
  87. ________ (See Chapter 10 for a description of the switch !*USERMODE which controls
  88. the printing of this message.)
  89. __ ____ _____ Basic PSL currently provides a single id hash table. PSL provides all
  90. the "hooks" to permit a package system to be loaded as an option; certain
  91. functions are redefined in this process. If the package system is loaded,
  92. __ ____ _____ a tree-structured id hash table can be created in which each level can be
  93. __ ____ _____ __ ______ thought of as a smaller id hash table. If a new id or string is to be
  94. interned, it is searched for in the tree according to a specified rule.
  95. For more information see Section 6.6.
  96. __ Information on converting ids to other types can be found in Chapter
  97. 12 and Section 4.3.
  98. 6.3.1. Identifier Functions 6.3.1. Identifier Functions 6.3.1. Identifier Functions
  99. __________ __ ____ _____ The following functions deal with identifiers and the id hash table.
  100. GenSym GenSym __ ____ (GenSym ): id expr
  101. __________ Creates an identifier which is not interned on the id hash table
  102. Eq Eq __ and consequently not Eq to anything else. The id is derived from
  103. a string of the form "G0000", which is incremented upon each call
  104. GenSym GenSym to GenSym.
  105. [??? Is this interned or recorded on the NIL package ???] [??? Is this interned or recorded on the NIL package ???] [??? Is this interned or recorded on the NIL package ???]
  106. [??? Can we change the GenSym string ???] [??? Can we change the GenSym string ???] [??? Can we change the GenSym string ???]
  107. InternGenSym InternGenSym __ ____ (InternGenSym ): id expr
  108. GenSym GenSym __ Similar to GenSym but returns an interned id.
  109. StringGenSym StringGenSym ______ ____ (StringGenSym ): string expr
  110. GenSym GenSym ______ Similar to GenSym but returns a string of the form "L0000"
  111. __ instead of an id. Identifiers 7 February 1983 PSL Manual
  112. page 6.4 section 6.3
  113. RemOb RemOb _ __ _ __ ____ (RemOb U:id): U:id expr
  114. _ If U is present on the current package search path it is removed.
  115. _ This does not affect U having properties, flags, functions and
  116. _ the like. U is returned.
  117. InternP InternP _ __ ______ _______ ____ (InternP U:{id,string}): boolean expr
  118. _ Returns T if U is interned in the current search path.
  119. MapObl MapObl _____ ________ _________ ____ (MapObl FNAME:function): Undefined expr
  120. MapObl MapObl _____ __ MapObl applies function FNAME to each id interned in the current
  121. hash table.
  122. 6.3.2. Find 6.3.2. Find 6.3.2. Find
  123. ______ __ __ ____ These functions take a string or id as an argument, and scan the id hash
  124. _____ __ table to collect a list of ids with prefix or suffix matching the argument.
  125. This is a loadable option (LOAD FIND).
  126. FindPrefix FindPrefix ___ __ ______ __ ____ ____ (FindPrefix KEY:{id, string}): id-list expr
  127. __ ____ _____ __ ___ Scans current id hash table for all ids whose prefix matches KEY.
  128. Returns all the identifiers found as an alphabetically sorted
  129. list.
  130. FindSuffix FindSuffix ___ __ ______ __ ____ ____ (FindSuffix KEY:{id, string}): id-list expr
  131. __ ____ _____ __ ___ Scans current id hash table for all ids whose suffix matches KEY.
  132. Returns all the identifiers found as an alphabetically sorted
  133. list.
  134. (Setq X (FindPrefix '!*) % Finds all identifiers starting with *
  135. (Setq Y (FindSuffix "STRING")) % Finds all identifiers ending with S
  136. 6.4. Property List Functions 6.4. Property List Functions 6.4. Property List Functions
  137. __________ ____ ____ The property cell of an identifier points to a "property list". The list
  138. __ is used to quickly associate an id name with a set of entities; those
  139. __ entities are called "flags" if their use gives the id a boolean value, and
  140. __ "properties" if the id is to have an arbitrary attribute (an indicator with
  141. a property). PSL Manual 7 February 1983 Identifiers
  142. section 6.4 page 6.5
  143. Put Put _ __ ___ __ ____ ___ ___ ____ (Put U:id IND:id PROP:any): any expr
  144. ___ ____ The indicator IND with the property PROP is placed on the
  145. Put ____ __ _ Put property list of the id U. If the action of Put occurs, the
  146. ____ _ ___ __ value of PROP is returned. If either of U and IND are not ids
  147. the type mismatch error occurs and no property is placed.
  148. (Put 'Jim 'Height 68)
  149. The above returns 68 and places (Height . 68) on the property
  150. __ list of the id Jim.
  151. Get Get _ __ ___ __ ___ ____ (Get U:id IND:id): any expr
  152. ___ Returns the property associated with indicator IND from the
  153. ____ _ _ ___ property list of U. If U does not have indicator IND, NIL is
  154. Get Get Get Get returned. (In older LISPs, Get could access functions.) Get
  155. _ __ returns NIL if U is not an id.
  156. (Get 'Jim 'Height) returns 68
  157. DefList DefList _ ____ ___ __ ____ ____ (DefList U:list IND:id): list expr
  158. _ U is a list in which each element is a two-element list:
  159. __ __ ____ ___ __ _ ___ (ID:ID PROP:ANY). Each id in U has the indicator IND with
  160. Put Put property PROP placed on its property list by the Put function.
  161. DefList DefList ____ The value of DefList is a list of the first elements of each
  162. Put DefList Put DefList two-element list. Like Put, DefList may not be used to define
  163. functions.
  164. (DE DEFLIST (U IND)
  165. (COND ((NULL U) NIL)
  166. (T (CONS(PROGN(PUT (CAAR U) IND (CADAR U))
  167. (CAAR U))
  168. (DEFLIST (CDR U) IND)))))
  169. RemProp RemProp _ __ ___ __ ___ ____ (RemProp U:id IND:id): any expr
  170. ___ ____ Removes the property with indicator IND from the property list of
  171. _ U. Returns the removed property or NIL if there was no such
  172. indicator.
  173. RemPropL RemPropL _ __ ____ ___ __ ___ ____ (RemPropL U:id-list IND:id): NIL expr
  174. ___ __ _ Remove property IND from all ids in U. Identifiers 7 February 1983 PSL Manual
  175. page 6.6 section 6.4
  176. 6.4.1. Functions for Flagging Ids 6.4.1. Functions for Flagging Ids 6.4.1. Functions for Flagging Ids
  177. __ In some LISPs, flags and indicators may clash. In PSL, flags are ids and
  178. ____ properties are pairs on the prop-list, so no clash occurs.
  179. Flag Flag _ __ ____ _ __ ___ ____ (Flag U:id-list V:id): NIL expr
  180. Flag Flag Flag __ _ _ Flag Flag flags each id in U with V; that is, the effect of Flag is
  181. FlagP __ _ _ FlagP _ that for each id X in U, FlagP(X, V) has the value T. Both V and
  182. _ __________ all the elements of U must be identifiers or the type mismatch
  183. Flag Flag __ _ error occurs. After Flagging, the id V appears on the property
  184. __ _ list of each id X in U. However, flags cannot be accessed,
  185. placed on, or removed from property lists using normal property
  186. Get Put RemProp Get Put RemProp list functions Get, Put, and RemProp. Note that if an error
  187. Flag Flag __ _ occurs during execution of Flag, then some of the ids on U may be
  188. _ flagged with V, and others may not be. The statement below
  189. causes the flag "Lose" to be placed on the property lists of the
  190. __ ids X and Y.
  191. (Flag '(X Y) 'Lose)
  192. FlagP FlagP _ __ _ __ _______ ____ (FlagP U:id V:id): boolean expr
  193. _ _ Returns T if U has been flagged with V; otherwise returns NIL.
  194. _ _ __ Returns NIL if either U or V is not an id.
  195. RemFlag RemFlag _ __ ____ _ __ ___ ____ (RemFlag U:id-list V:id): NIL expr
  196. _ ____ Removes the flag V from the property list of each member of the
  197. ____ _ _ _ __ list U. Both V and all the elements of U must be ids or the type
  198. mismatch error occurs.
  199. Flag1 Flag1 _ __ _ ___ _________ ____ (Flag1 U:id V:any): Undefined expr
  200. _ __ _ Puts flag V on the property list of id U.
  201. RemFlag1 RemFlag1 _ __ _ ___ _________ ____ (RemFlag1 U:id V:any): Undefined expr
  202. _ __ _ Removes the flag V from the property list of id U.
  203. [??? Make Flag1 and RemFlag1 return single value. ???] [??? Make Flag1 and RemFlag1 return single value. ???] [??? Make Flag1 and RemFlag1 return single value. ???] PSL Manual 7 February 1983 Identifiers
  204. section 6.4 page 6.7
  205. 6.4.2. Direct Access to the Property Cell 6.4.2. Direct Access to the Property Cell 6.4.2. Direct Access to the Property Cell
  206. Use of the following functions can destroy the integrity of the property
  207. ____ list. Since PSL uses properties at a low level, care should be taken in
  208. the use of these functions.
  209. Prop Prop _ __ ___ ____ (Prop U:id): any expr
  210. ____ _ Returns the property list of U.
  211. SetProp SetProp _ __ _ ___ _ ___ ____ (SetProp U:id L:any): L:any expr
  212. _ ____ _ Store item L as the property list of U.
  213. 6.5. Value Cell Functions 6.5. Value Cell Functions 6.5. Value Cell Functions
  214. Eval Eval The contents of the value cell are usually accessed by Eval (Chapter 11)
  215. ValueCell Set SetQ ValueCell Set SetQ or ValueCell (below) and changed by Set or SetQ.
  216. Set Set ___ __ _____ ___ ___ ____ (Set EXP:id VALUE:any): any expr
  217. ___ __________ EXP must be an identifier or a type mismatch error occurs. The
  218. Set Set effect of Set is replacement of the item bound to the identifier
  219. _____ by VALUE. If the identifier is not a LOCAL variable or has not
  220. been declared GLOBAL, it is automatically declared FLUID with the
  221. resulting warning message:
  222. *** EXP declared FLUID
  223. ___ EXP must not evaluate to T or NIL or an error occurs:
  224. ***** Cannot change T or NIL
  225. SetQ SetQ ________ __ _____ ___ ___ _____ (SetQ VARIABLE:id VALUE:any): any fexpr
  226. ________ The value of the current binding of VARIABLE is replaced by the
  227. _____ value of VALUE.
  228. (SETQ X 1)
  229. is equivalent to
  230. (SET 'X 1)
  231. SetQ SetQ SetQ now conforms to the Common LISP standard, allowing
  232. sequential assignment: Identifiers 7 February 1983 PSL Manual
  233. page 6.8 section 6.5
  234. (SETQ A 1 B 2)
  235. ==> (SETQ A 1)
  236. (SETQ B 2)
  237. DeSetQ DeSetQ _ ___ _ ___ _ ___ _____ (DeSetQ U:any V:any): V:any macro
  238. DeSetQ DeSetQ This is a function in "USEFUL" (Load USEFUL; in RLISP). DeSetQ
  239. SetQ SetQ is a destructuring SetQ. That is, the first argument is a piece
  240. SetQ ____ ____ __ SetQ of list structure whose atoms are all ids. Each is SetQ'd to the
  241. corresponding part of the second argument. For instance
  242. (DeSetQ (a (b) . c) '((1) (2) (3) 4))
  243. SetQ SetQ SetQ's a to (1), b to 2, and c to ((3) 4).
  244. PSetQ PSetQ ________ __ _____ ___ _________ _____ (PSetQ [VARIABLE:id VALUE:any]): Undefined macro
  245. Part of the USEFUL package (LOAD USEFUL).
  246. (PSETQ VAR1 VAL1 VAR2 VAL2 ... VARn VALn)
  247. SetQ SetQ SetQ's the VAR's to the corresponding VAL's. The VAL's are all
  248. evaluated before any assignments are made. That is, this is a
  249. SetQ SetQ parallel SetQ.
  250. SetF SetF ___ ____ ___ ___ ___ ___ _____ (SetF [LHS:form RHS:any]): RHS:any macro
  251. SetF SetF SetF SetF There are two versions of SetF. SetF is redefined on loading
  252. SetF SetF SetF SetF USEFUL. The description below is for the resident SetF. SetF
  253. provides a method for assigning values to expressions more
  254. __ general than simple ids. For example:
  255. (SETF (CAR X) 2)
  256. ==> CAR X := 2;
  257. is equivalent to
  258. (RPLACA X 2)
  259. SetF SetF In general, SetF has the form
  260. (SetF LHS RHS)
  261. ___ ___ in which LHS is the "left hand side" to be assigned to and RHS is
  262. ___ evaluated to the value to be assigned. LHS can be one of the
  263. following:
  264. SetQ __ SetQ id SetQ is used to assign a value to the PSL Manual 7 February 1983 Identifiers
  265. section 6.5 page 6.9
  266. __ id.
  267. Eval Set SetQ Eval Set SetQ (Eval expression) Set is used instead of SetQ. In
  268. Eval Eval effect, the "Eval" cancels out the
  269. Quote Quote "Quote" which would normally be used.
  270. Value Eval Value Eval (Value expression) Is treated the same as Eval.
  271. Car RplacA Car ____ RplacA (Car pair) RplacA is used to store into the Car
  272. "field".
  273. Cdr RplacD Cdr ____ RplacD (Cdr pair) RplacD is used to store into the Cdr
  274. "field".
  275. GetV PutV GetV ______ PutV (GetV vector) PutV is used to store into the
  276. appropriate location.
  277. Indx SetIndx Indx SetIndx (Indx "indexable object") SetIndx is used to store into the
  278. object.
  279. Sub SetSub Sub ______ SetSub (Sub vector) SetSub is used to store into the
  280. appropriate subrange of the vector.
  281. Car Cdr SetF ___ Car ____ Cdr ____ SetF Note that if the LHS is (Car pair) or (Cdr pair), SetF returns
  282. SetF RplacA ___ SetF RplacA the modified pair instead of the RHS, because SetF uses RplacA
  283. RplacD RplacD and RplacD in these cases.
  284. SetF Caar Cadr SetF Caar Cadr Loading USEFUL brings in declarations to SetF about Caar, Cadr,
  285. Cddddr Cddddr ... Cddddr. This is rather handy with constructor/selector
  286. Cadadr Cadadr macros. For instance, if FOO is a selector which maps to Cadadr,
  287. (SETF (FOO X) Y)
  288. works; that is, it maps to something which does a
  289. (RPLACA (CDADR X) Y)
  290. and then returns X.
  291. PSetF PSetF ___ ____ ___ ___ _________ _____ (PSetF [LHS:form RHS:any]): Undefined macro
  292. PSetF SetF PSetF SetF Part of the USEFUL package (LOAD USEFUL). PSetF does a SetF in
  293. ___ parallel: i.e. it evaluates all the right hand sides (RHS) before
  294. ___ assigning any to the left hand sides (LHS).
  295. MakeUnBound MakeUnBound _ __ _________ ____ (MakeUnBound U:id): Undefined expr
  296. _ __ Make U an unbound id by storing a "magic" number in the value
  297. cell.
  298. ValueCell ValueCell _ __ ___ ____ (ValueCell U:id): any expr
  299. __ _ Safe access to the value cell of an id. If U is not an id a type
  300. _ mismatch error is signalled; if U is an unbound id, an unbound id Identifiers 7 February 1983 PSL Manual
  301. page 6.10 section 6.5
  302. _ error is signalled. Otherwise the current value of U is
  303. Value LispVar Value LispVar returned. [See also the Value and LispVar functions, described
  304. in Chapter 20, for more direct access].
  305. UnBoundP UnBoundP _ __ _______ ____ (UnBoundP U:id): boolean expr
  306. _ Tests whether U has no value.
  307. [??? Define and describe General Property LISTs or hash-tables. See [??? Define and describe General Property LISTs or hash-tables. See [??? Define and describe General Property LISTs or hash-tables. See
  308. Hcons. ???] Hcons. ???] Hcons. ???]
  309. 6.6. Package System Functions 6.6. Package System Functions 6.6. Package System Functions
  310. To get the package system (Load Package). An example of the use of this
  311. system is at the end of this section.
  312. The character "\" is normally reserved in the basic Read-Table (see
  313. Chapter 12) to make up multi-part names of the form "PackageName\LocalId".
  314. If the package system is loaded, the Intern process starts searching a path
  315. in a linked structure from "PackageName", itself an id accessible in the
  316. "CurrentPackage". The print-name is still "LocalId", but the additional
  317. Prin1 Prin2 Prin1 Prin2 package field in each id records "PackageName". Prin1 and Prin2 are
  318. modified to access this field in loading the package system. The root of
  319. the tree is the GLOBAL package, indicated by \. If the package system is
  320. loaded, the basic id hash table is made into the GLOBAL package. Thus \ID
  321. is guaranteed in the root (in fact the pre-existing id hash table).
  322. [??? Explain further or at least more clearly. ???] [??? Explain further or at least more clearly. ???] [??? Explain further or at least more clearly. ???]
  323. The following fluid variables are managed by the package system.
  324. __________ ______ \CURRENTPACKAGE!* [Initially: Global] global
  325. This is the start of the search path if interning.
  326. \CurrentPackage!* \CurrentPackage!* \CurrentPackage!* is rebound in the token scanner on encountering
  327. a "\".
  328. __________ ______ \PACKAGENAMES!* [Initially: (Global)] global
  329. List of ALL package names currently created.
  330. Our current package model uses a set of general path functions that
  331. access functions specific to each level of the id hash table tree to do
  332. various things: "Localxxxx(s)" and "Pathxxxx(s)" in which "xxxx" is one of
  333. InternP, Intern, RemOb, MapObl InternP, Intern, RemOb, MapObl the set (InternP, Intern, RemOb, MapObl). By storing different functions,
  334. each package may have a different structure and associated functions. The
  335. ______ current implementation of a package uses a vector PSL Manual 7 February 1983 Identifiers
  336. section 6.6 page 6.11
  337. [Name Father GetFn PutFn RemFn MapFn]
  338. __ stored under the indicator 'Package on the PackageName id.
  339. A simple bucket id hash table can also be used for experiments, or the
  340. user can build his own. As far as possible, each function checks that a
  341. legal package is given before performing the operation.
  342. [??? Should we have a package Tag ???] [??? Should we have a package Tag ???] [??? Should we have a package Tag ???]
  343. The following functions should be used.
  344. \CreatePackage \CreatePackage ____ __ _____________ __ __ ____ (\CreatePackage NAME:id FATHERPACKAGE:id): id expr
  345. This creates a convenient size id hash table, generates the
  346. functions to manage it for this package, and links the new
  347. _____________ package to the FATHERPACKAGE so that path searches for ids are
  348. required.
  349. \SetPackage \SetPackage ____ __ __ ____ (\SetPackage NAME:id): id expr
  350. ______ Selects another package such as GLOBAL\.
  351. \PathInternP \PathInternP _ __ ______ _______ ____ (\PathInternP S:{id string}): boolean expr
  352. _ Searches from CurrentPackage!* to see if S is interned.
  353. \PathIntern \PathIntern _ __ ______ __ ____ (\PathIntern S:{id string}): id expr
  354. __ Look up or insert an id.
  355. \PathRemob \PathRemob _ __ ______ __ ____ (\PathRemob S:{id string}): id expr
  356. Remobs, puts in NIL package.
  357. \PathMapObl \PathMapObl _ ________ ___ ____ (\PathMapObl F:function): NIL expr
  358. _ __ Applies F to ALL ids in path.
  359. \LocalInternP \LocalInternP _ __ ______ _______ ____ (\LocalInternP S:{id string}): boolean expr
  360. Searches in CURRENTPACKAGE!*. Identifiers 7 February 1983 PSL Manual
  361. page 6.12 section 6.6
  362. \LocalIntern \LocalIntern _ __ ______ __ ____ (\LocalIntern S:{id string}): id expr
  363. __ Look up or insert in CURRENTPACKAGE!* (forces ids uninterned in
  364. CURRENTPACKAGE!* into CURRENTPACKAGE!*) .
  365. \LocalRemob \LocalRemob _ __ ______ __ ____ (\LocalRemob S:{id string}): id expr
  366. Remobs, puts in NIL package.
  367. \LocalMapObl \LocalMapObl _ ________ ___ ____ (\LocalMapObl F:function): NIL expr
  368. _ __ Applies F to ALL ids in (CurrentPackage!*).
  369. ______ Note that if a string is used, it CANNOT include the \. Also, since most
  370. __ ids are "RAISED" on input, be careful.
  371. \PathIntern \PathIntern Current intern, etc. are \PathIntern, etc.
  372. Several restrictions are placed on the use of packages when compiled.
  373. Since it is a loaded module and not integrated with the basic PSL system,
  374. all ids in the compiled package are Interned in Global\ before they are
  375. defined. This requires a slightly more complex loading system for
  376. packages. Names and function ids which conflict with names in Global\ (or
  377. other packages in the path) must be forced into the id hash table of the
  378. desired package. The package is compiled WITHOUT the package module
  379. loaded.
  380. In addition, if a function call must be issued for a function which has
  381. been redefined in the package the function name must be changed. When
  382. Fasl Fasl PACKAGE has been integrated with Fasl and PSL, it will be sufficient to
  383. prefix the function name with the package name (e.g. Global\Print).
  384. Currently, one must actually change the function name (e.g. Global!.Print).
  385. Other problems in the package system include:
  386. a. Single character identifiers are handled specially (i.e. not
  387. interned) and therefore may not be used in any packages without
  388. doing an explicit intern
  389. b. By leaving the the package identifier and '\' off the identifier
  390. will place it in the Global\ package instead of the current
  391. package
  392. c. If an identifier is installed in the Global\ package, then
  393. reference to it with another package identifier will return the
  394. Global\ value instead of issuing an error
  395. Print Print As an example, a small package which redefines the system function Print PSL Manual 7 February 1983 Identifiers
  396. section 6.6 page 6.13
  397. is shown. The assumed file name is PrintPack.SL.
  398. (De GetFieldFn (Relation Field)
  399. (Slotdescslotfn
  400. (Cdr (Assoc Field
  401. (Dsdescslotalist Getdefstruct Relation)))))
  402. (Df Print (Args)
  403. (Prog (Fields)
  404. (Setq Fields (Get (Car Args) 'Fields))
  405. (Foreach Elem In (Eval (Car Args)) Do
  406. (Cons
  407. Global!.Print
  408. (Foreach Field In Fields Collect
  409. (Apply (GetFieldFn
  410. (Car Args) Field) ('List Elem)))))
  411. (Return (Car Args))))
  412. This package would be compiled as follows (immediately after entering
  413. PSL):
  414. (Faslout "PrintPackage")
  415. (Dskin "PrintPack.SL"$)
  416. (Faslend)
  417. (Quit)
  418. This package would be loaded as follows (immediately after entering PSL):
  419. (Load '(Defstruct Package))
  420. (CopyD 'Global!.Print Print)
  421. (Progn (\CreatePackage 'PrintPack 'Global)
  422. (\SetPAckage 'PrintPack)
  423. (LocalIntern 'Print))
  424. (Faslin "PrintPack.B")
  425. 6.7. System Global Variables, Switches and Other "Hooks" 6.7. System Global Variables, Switches and Other "Hooks" 6.7. System Global Variables, Switches and Other "Hooks"
  426. 6.7.1. Introduction 6.7.1. Introduction 6.7.1. Introduction
  427. A number of global variables provide global control of the LISP system,
  428. or implement values which are constant throughout execution. Certain
  429. options are controlled by switches, with T or NIL properties (e.g. ECHOing
  430. as a file is read in); others require a value, such as an integer for the
  431. current output base. PSL has the convention (following the REDUCE/RLISP
  432. convention) of using a "!*" in the name of the variable: !*XXXXX for GLOBAL
  433. variables expecting a T/NIL value (called "switches"), and XXXXX!* for
  434. other GLOBALs. Chapter 26 is an index of switches and global variables
  435. used in PSL. Identifiers 7 February 1983 PSL Manual
  436. page 6.14 section 6.7
  437. [??? These should all be FLUIDs, so that ANY one of these variables may [??? These should all be FLUIDs, so that ANY one of these variables may [??? These should all be FLUIDs, so that ANY one of these variables may
  438. be rebound, as appropriate ???] be rebound, as appropriate ???] be rebound, as appropriate ???]
  439. 6.7.2. Setting Switches 6.7.2. Setting Switches 6.7.2. Setting Switches
  440. Strictly speaking, XXXX is a switch and !*XXXX is a corresponding global
  441. variable that assumes the T/NIL value; both are loosely referred to as
  442. switches elsewhere in the manual.
  443. On Off On Off The On and Off functions are used to change the values of the variables
  444. associated with switches. Some switches contain an s-expression on their
  445. 1
  446. property lists under the indicator 'SIMPFG . The s-expression has the form
  447. Cond Cond of a Cond list:
  448. ((T (action-for-ON)) (NIL (action-for-OFF)))
  449. On Off On Off If the 'SIMPFG indicator is present, then the On and Off functions also
  450. evaluate the appropriate action in the s-expression.
  451. On On _ __ ____ _____ (On [U:id]): None macro
  452. _ For each U, the associated !*U variable is set to T. If a "(T
  453. GET GET _ (action-for-ON))" clause is found by (GET U 'SIMPFG), the
  454. "action" is EVAL'ed.
  455. Off Off _ __ ____ _____ (Off [U:id]): None macro
  456. _ For each U, the associated !*U variable is set to NIL. If a
  457. GET GET _ "(NIL (action-for-OFF)" clause is found by (GET U 'SIMPFG), the
  458. "action" is EVAL'ed.
  459. (On Comp Ord Usermode)
  460. will set !*Comp, !*Ord, and !*Usermode to T.
  461. Note that
  462. _______________
  463. 1
  464. The name SIMPFG comes from its introduction in the REDUCE algebra
  465. system, where it was used as a "simp flag" to specify various
  466. simplifications to be performed as various switches were turned on or off. PSL Manual 7 February 1983 Identifiers
  467. section 6.7 page 6.15
  468. (Get 'Cref 'Simpfg)
  469. returns
  470. ((T (Crefon)) (Nil (Crefoff)))
  471. ____ ____ Setting CREF on will result in !*CREF being set to T and the function
  472. Crefon Crefon Crefon being evaluated.
  473. 6.7.3. Special Global Variables 6.7.3. Special Global Variables 6.7.3. Special Global Variables
  474. __________ ______ NIL [Initially: NIL] global
  475. NIL is a special GLOBAL variable. It is protected from being
  476. Set SetQ Set SetQ modified by Set or SetQ.
  477. __________ ______ T [Initially: T] global
  478. T is a special GLOBAL variable. It is protected from being
  479. Set SetQ Set SetQ modified by Set or SetQ.
  480. 6.7.4. Special Put Indicators 6.7.4. Special Put Indicators 6.7.4. Special Put Indicators
  481. __ Some actions search the property list of relevant ids for these
  482. indicators:
  483. __ 'HELPFUNCTION An id, a function to be executed to give help about the
  484. topic; ideally for a complex topic, a clever function is
  485. used.
  486. 'HELPSTRING A help string, kept in core for important or short topics.
  487. 'HELPFILE The most common case, the name of a file to print; later we
  488. hope to load this file into an EMODE buffer for perusal in a
  489. window.
  490. 'SWITCHINFO A string describing the purpose of the SWITCH, see
  491. ShowSwitches ShowSwitches ShowSwitches below.
  492. 'GLOBALINFO A string describing the purpose of the GLOBAL, see
  493. ShowGlobals ShowGlobals ShowGlobals below.
  494. __ 'BREAKFUNCTION Associates a function to be run with an Id typed at Break
  495. Loop, see Chapter 14.
  496. 'TYPE PSL uses the property TYPE to indicate whether a function is
  497. a FEXPR, MACRO, or NEXPR; if no property is present, EXPR is Identifiers 7 February 1983 PSL Manual
  498. page 6.16 section 6.7
  499. assumed.
  500. 'VARTYPE PSL uses the property VARTYPE to indicate whether an
  501. __________ identifier is of type GLOBAL or FLUID.
  502. '!*LAMBDALINK The interpreter also looks under '!*LAMBDALINK for a Lambda
  503. expression, if a procedure is not compiled.
  504. 6.7.5. Special Flag Indicators 6.7.5. Special Flag Indicators 6.7.5. Special Flag Indicators
  505. __ 'EVAL If the id is flagged EVAL, the RLISP top-loop evaluates and
  506. On Defn __ On Defn outputs any expression (id ...) in On Defn (!*DEFN := T) mode.
  507. __ 'IGNORE If the id is flagged IGNORE, the RLISP top-loop evaluates but
  508. On Defn __ On Defn does NOT output any expression (id ...) in On Defn (!*DEFN := T)
  509. mode.
  510. PutD __ PutD 'LOSE If an id has the 'LOSE flag, it will not be defined by PutD when
  511. it is read in.
  512. 'USER 'USER is put on all functions defined when in !*USERMODE, to
  513. distinguish them from "system" functions. See Chapter 10.
  514. LoadTime CompileTime LoadTime CompileTime See also the functions LoadTime and CompileTime in Chapter 18.
  515. [??? Mention Parser properties ???] [??? Mention Parser properties ???] [??? Mention Parser properties ???]
  516. 6.7.6. Displaying Information About Globals 6.7.6. Displaying Information About Globals 6.7.6. Displaying Information About Globals
  517. Help Help The Help function has two options, (HELP SWITCHES) and (HELP GLOBALS),
  518. which should display the current state of a variety of switches and globals
  519. respectively. These calls have the same effect as using the functions
  520. below, using an initial table of Switches and Globals.
  521. ShowSwitches ShowSwitches The function (ShowSwitches switch-list) may be used to print names,
  522. current settings and purpose of some switches. Use NIL as the switch-list
  523. ShowSwitches ShowSwitches to get information on ALL switches of interest; ShowSwitches in this case
  524. MapObl MapObl does a MapObl (Section 6.3.1) looking for 'SwitchInfo property.
  525. ShowGlobals ShowGlobals Similarly, (ShowGlobals global-list) may be used to print names, values
  526. and purposes of important GLOBALs. Again, NIL used as the global-list
  527. ShowGlobals MapObl ShowGlobals MapObl causes ShowGlobals to do a MapObl looking for a 'GlobalInfo property; the
  528. result is some information about all globals of interest.