Commit | Line | Data |
---|---|---|
a0e07ba4 NJ |
1 | |
2 | @c module (guile) | |
3 | ||
4 | @deffn primitive environment? obj | |
5 | Return @code{#t} if @var{obj} is an environment, or @code{#f} | |
6 | otherwise. | |
7 | @end deffn | |
8 | ||
9 | @deffn primitive environment-bound? env sym | |
10 | Return @code{#t} if @var{sym} is bound in @var{env}, or | |
11 | @code{#f} otherwise. | |
12 | @end deffn | |
13 | ||
14 | @deffn primitive environment-ref env sym | |
15 | Return the value of the location bound to @var{sym} in | |
16 | @var{env}. If @var{sym} is unbound in @var{env}, signal an | |
17 | @code{environment:unbound} error. | |
18 | @end deffn | |
19 | ||
20 | @deffn primitive environment-fold env proc init | |
21 | Iterate over all the bindings in @var{env}, accumulating some | |
22 | value. | |
23 | For each binding in @var{env}, apply @var{proc} to the symbol | |
24 | bound, its value, and the result from the previous application | |
25 | of @var{proc}. | |
26 | Use @var{init} as @var{proc}'s third argument the first time | |
27 | @var{proc} is applied. | |
28 | If @var{env} contains no bindings, this function simply returns | |
29 | @var{init}. | |
30 | If @var{env} binds the symbol sym1 to the value val1, sym2 to | |
31 | val2, and so on, then this procedure computes: | |
32 | @lisp | |
33 | (proc sym1 val1 | |
34 | (proc sym2 val2 | |
35 | ... | |
36 | (proc symn valn | |
37 | init))) | |
38 | @end lisp | |
39 | Each binding in @var{env} will be processed exactly once. | |
40 | @code{environment-fold} makes no guarantees about the order in | |
41 | which the bindings are processed. | |
42 | Here is a function which, given an environment, constructs an | |
43 | association list representing that environment's bindings, | |
44 | using environment-fold: | |
45 | @lisp | |
46 | (define (environment->alist env) | |
47 | (environment-fold env | |
48 | (lambda (sym val tail) | |
49 | (cons (cons sym val) tail)) | |
50 | '())) | |
51 | @end lisp | |
52 | @end deffn | |
53 | ||
54 | @deffn primitive environment-define env sym val | |
55 | Bind @var{sym} to a new location containing @var{val} in | |
56 | @var{env}. If @var{sym} is already bound to another location | |
57 | in @var{env} and the binding is mutable, that binding is | |
58 | replaced. The new binding and location are both mutable. The | |
59 | return value is unspecified. | |
60 | If @var{sym} is already bound in @var{env}, and the binding is | |
61 | immutable, signal an @code{environment:immutable-binding} error. | |
62 | @end deffn | |
63 | ||
64 | @deffn primitive environment-undefine env sym | |
65 | Remove any binding for @var{sym} from @var{env}. If @var{sym} | |
66 | is unbound in @var{env}, do nothing. The return value is | |
67 | unspecified. | |
68 | If @var{sym} is already bound in @var{env}, and the binding is | |
69 | immutable, signal an @code{environment:immutable-binding} error. | |
70 | @end deffn | |
71 | ||
72 | @deffn primitive environment-set! env sym val | |
73 | If @var{env} binds @var{sym} to some location, change that | |
74 | location's value to @var{val}. The return value is | |
75 | unspecified. | |
76 | If @var{sym} is not bound in @var{env}, signal an | |
77 | @code{environment:unbound} error. If @var{env} binds @var{sym} | |
78 | to an immutable location, signal an | |
79 | @code{environment:immutable-location} error. | |
80 | @end deffn | |
81 | ||
82 | @deffn primitive environment-cell env sym for_write | |
83 | Return the value cell which @var{env} binds to @var{sym}, or | |
84 | @code{#f} if the binding does not live in a value cell. | |
85 | The argument @var{for-write} indicates whether the caller | |
86 | intends to modify the variable's value by mutating the value | |
87 | cell. If the variable is immutable, then | |
88 | @code{environment-cell} signals an | |
89 | @code{environment:immutable-location} error. | |
90 | If @var{sym} is unbound in @var{env}, signal an | |
91 | @code{environment:unbound} error. | |
92 | If you use this function, you should consider using | |
93 | @code{environment-observe}, to be notified when @var{sym} gets | |
94 | re-bound to a new value cell, or becomes undefined. | |
95 | @end deffn | |
96 | ||
97 | @deffn primitive environment-observe env proc | |
98 | Whenever @var{env}'s bindings change, apply @var{proc} to | |
99 | @var{env}. | |
100 | This function returns an object, token, which you can pass to | |
101 | @code{environment-unobserve} to remove @var{proc} from the set | |
102 | of procedures observing @var{env}. The type and value of | |
103 | token is unspecified. | |
104 | @end deffn | |
105 | ||
106 | @deffn primitive environment-observe-weak env proc | |
107 | This function is the same as environment-observe, except that | |
108 | the reference @var{env} retains to @var{proc} is a weak | |
109 | reference. This means that, if there are no other live, | |
110 | non-weak references to @var{proc}, it will be | |
111 | garbage-collected, and dropped from @var{env}'s | |
112 | list of observing procedures. | |
113 | @end deffn | |
114 | ||
115 | @deffn primitive environment-unobserve token | |
116 | Cancel the observation request which returned the value | |
117 | @var{token}. The return value is unspecified. | |
118 | If a call @code{(environment-observe env proc)} returns | |
119 | @var{token}, then the call @code{(environment-unobserve token)} | |
120 | will cause @var{proc} to no longer be called when @var{env}'s | |
121 | bindings change. | |
122 | @end deffn | |
123 | ||
124 | @deffn primitive make-leaf-environment | |
125 | Create a new leaf environment, containing no bindings. | |
126 | All bindings and locations created in the new environment | |
127 | will be mutable. | |
128 | @end deffn | |
129 | ||
130 | @deffn primitive leaf-environment? object | |
131 | Return @code{#t} if object is a leaf environment, or @code{#f} | |
132 | otherwise. | |
133 | @end deffn | |
134 | ||
135 | @deffn primitive make-eval-environment local imported | |
136 | Return a new environment object eval whose bindings are the | |
137 | union of the bindings in the environments @var{local} and | |
138 | @var{imported}, with bindings from @var{local} taking | |
139 | precedence. Definitions made in eval are placed in @var{local}. | |
140 | Applying @code{environment-define} or | |
141 | @code{environment-undefine} to eval has the same effect as | |
142 | applying the procedure to @var{local}. | |
143 | Note that eval incorporates @var{local} and @var{imported} by | |
144 | reference: | |
145 | If, after creating eval, the program changes the bindings of | |
146 | @var{local} or @var{imported}, those changes will be visible | |
147 | in eval. | |
148 | Since most Scheme evaluation takes place in eval environments, | |
149 | they transparently cache the bindings received from @var{local} | |
150 | and @var{imported}. Thus, the first time the program looks up | |
151 | a symbol in eval, eval may make calls to @var{local} or | |
152 | @var{imported} to find their bindings, but subsequent | |
153 | references to that symbol will be as fast as references to | |
154 | bindings in finite environments. | |
155 | In typical use, @var{local} will be a finite environment, and | |
156 | @var{imported} will be an import environment | |
157 | @end deffn | |
158 | ||
159 | @deffn primitive eval-environment? object | |
160 | Return @code{#t} if object is an eval environment, or @code{#f} | |
161 | otherwise. | |
162 | @end deffn | |
163 | ||
164 | @deffn primitive eval-environment-local env | |
165 | Return the local environment of eval environment @var{env}. | |
166 | @end deffn | |
167 | ||
168 | @deffn primitive eval-environment-set-local! env local | |
169 | Change @var{env}'s local environment to @var{local}. | |
170 | @end deffn | |
171 | ||
172 | @deffn primitive eval-environment-imported env | |
173 | Return the imported environment of eval environment @var{env}. | |
174 | @end deffn | |
175 | ||
176 | @deffn primitive eval-environment-set-imported! env imported | |
177 | Change @var{env}'s imported environment to @var{imported}. | |
178 | @end deffn | |
179 | ||
180 | @deffn primitive make-import-environment imports conflict_proc | |
181 | Return a new environment @var{imp} whose bindings are the union | |
182 | of the bindings from the environments in @var{imports}; | |
183 | @var{imports} must be a list of environments. That is, | |
184 | @var{imp} binds a symbol to a location when some element of | |
185 | @var{imports} does. | |
186 | If two different elements of @var{imports} have a binding for | |
187 | the same symbol, the @var{conflict-proc} is called with the | |
188 | following parameters: the import environment, the symbol and | |
189 | the list of the imported environments that bind the symbol. | |
190 | If the @var{conflict-proc} returns an environment @var{env}, | |
191 | the conflict is considered as resolved and the binding from | |
192 | @var{env} is used. If the @var{conflict-proc} returns some | |
193 | non-environment object, the conflict is considered unresolved | |
194 | and the symbol is treated as unspecified in the import | |
195 | environment. | |
196 | The checking for conflicts may be performed lazily, i. e. at | |
197 | the moment when a value or binding for a certain symbol is | |
198 | requested instead of the moment when the environment is | |
199 | created or the bindings of the imports change. | |
200 | All bindings in @var{imp} are immutable. If you apply | |
201 | @code{environment-define} or @code{environment-undefine} to | |
202 | @var{imp}, Guile will signal an | |
203 | @code{environment:immutable-binding} error. However, | |
204 | notice that the set of bindings in @var{imp} may still change, | |
205 | if one of its imported environments changes. | |
206 | @end deffn | |
207 | ||
208 | @deffn primitive import-environment? object | |
209 | Return @code{#t} if object is an import environment, or | |
210 | @code{#f} otherwise. | |
211 | @end deffn | |
212 | ||
213 | @deffn primitive import-environment-imports env | |
214 | Return the list of environments imported by the import | |
215 | environment @var{env}. | |
216 | @end deffn | |
217 | ||
218 | @deffn primitive import-environment-set-imports! env imports | |
219 | Change @var{env}'s list of imported environments to | |
220 | @var{imports}, and check for conflicts. | |
221 | @end deffn | |
222 | ||
223 | @deffn primitive make-export-environment private signature | |
224 | Return a new environment @var{exp} containing only those | |
225 | bindings in private whose symbols are present in | |
226 | @var{signature}. The @var{private} argument must be an | |
227 | environment. | |
228 | ||
229 | The environment @var{exp} binds symbol to location when | |
230 | @var{env} does, and symbol is exported by @var{signature}. | |
231 | ||
232 | @var{signature} is a list specifying which of the bindings in | |
233 | @var{private} should be visible in @var{exp}. Each element of | |
234 | @var{signature} should be a list of the form: | |
235 | (symbol attribute ...) | |
236 | where each attribute is one of the following: | |
237 | @table @asis | |
238 | @item the symbol @code{mutable-location} | |
239 | @var{exp} should treat the | |
240 | location bound to symbol as mutable. That is, @var{exp} | |
241 | will pass calls to @code{environment-set!} or | |
242 | @code{environment-cell} directly through to private. | |
243 | @item the symbol @code{immutable-location} | |
244 | @var{exp} should treat | |
245 | the location bound to symbol as immutable. If the program | |
246 | applies @code{environment-set!} to @var{exp} and symbol, or | |
247 | calls @code{environment-cell} to obtain a writable value | |
248 | cell, @code{environment-set!} will signal an | |
249 | @code{environment:immutable-location} error. Note that, even | |
250 | if an export environment treats a location as immutable, the | |
251 | underlying environment may treat it as mutable, so its | |
252 | value may change. | |
253 | @end table | |
254 | It is an error for an element of signature to specify both | |
255 | @code{mutable-location} and @code{immutable-location}. If | |
256 | neither is specified, @code{immutable-location} is assumed. | |
257 | ||
258 | As a special case, if an element of signature is a lone | |
259 | symbol @var{sym}, it is equivalent to an element of the form | |
260 | @code{(sym)}. | |
261 | ||
262 | All bindings in @var{exp} are immutable. If you apply | |
263 | @code{environment-define} or @code{environment-undefine} to | |
264 | @var{exp}, Guile will signal an | |
265 | @code{environment:immutable-binding} error. However, | |
266 | notice that the set of bindings in @var{exp} may still change, | |
267 | if the bindings in private change. | |
268 | @end deffn | |
269 | ||
270 | @deffn primitive export-environment? object | |
271 | Return @code{#t} if object is an export environment, or | |
272 | @code{#f} otherwise. | |
273 | @end deffn | |
274 | ||
275 | @deffn primitive export-environment-private env | |
276 | Return the private environment of export environment @var{env}. | |
277 | @end deffn | |
278 | ||
279 | @deffn primitive export-environment-set-private! env private | |
280 | Change the private environment of export environment @var{env}. | |
281 | @end deffn | |
282 | ||
283 | @deffn primitive export-environment-signature env | |
284 | Return the signature of export environment @var{env}. | |
285 | @end deffn | |
286 | ||
287 | @deffn primitive export-environment-set-signature! env signature | |
288 | Change the signature of export environment @var{env}. | |
289 | @end deffn | |
290 | ||
291 | @deffn primitive %compute-slots class | |
292 | Return a list consisting of the names of all slots belonging to | |
293 | class @var{class}, i. e. the slots of @var{class} and of all of | |
294 | its superclasses. | |
295 | @end deffn | |
296 | ||
297 | @deffn primitive get-keyword key l default_value | |
298 | Determine an associated value for the keyword @var{key} from | |
299 | the list @var{l}. The list @var{l} has to consist of an even | |
300 | number of elements, where, starting with the first, every | |
301 | second element is a keyword, followed by its associated value. | |
302 | If @var{l} does not hold a value for @var{key}, the value | |
303 | @var{default_value} is returned. | |
304 | @end deffn | |
305 | ||
306 | @deffn primitive slot-ref-using-class class obj slot_name | |
307 | @end deffn | |
308 | ||
309 | @deffn primitive slot-set-using-class! class obj slot_name value | |
310 | @end deffn | |
311 | ||
312 | @deffn primitive class-of x | |
313 | Return the class of @var{x}. | |
314 | @end deffn | |
315 | ||
316 | @deffn primitive %goops-loaded | |
317 | Announce that GOOPS is loaded and perform initialization | |
318 | on the C level which depends on the loaded GOOPS modules. | |
319 | @end deffn | |
320 | ||
321 | @deffn primitive %method-more-specific? m1 m2 targs | |
322 | @end deffn | |
323 | ||
324 | @deffn primitive find-method . l | |
325 | @end deffn | |
326 | ||
327 | @deffn primitive primitive-generic-generic subr | |
328 | @end deffn | |
329 | ||
330 | @deffn primitive enable-primitive-generic! . subrs | |
331 | @end deffn | |
332 | ||
333 | @deffn primitive generic-capability? proc | |
334 | @end deffn | |
335 | ||
336 | @deffn primitive %invalidate-method-cache! gf | |
337 | @end deffn | |
338 | ||
339 | @deffn primitive %invalidate-class class | |
340 | @end deffn | |
341 | ||
342 | @deffn primitive %modify-class old new | |
343 | @end deffn | |
344 | ||
345 | @deffn primitive %modify-instance old new | |
346 | @end deffn | |
347 | ||
348 | @deffn primitive %set-object-setter! obj setter | |
349 | @end deffn | |
350 | ||
351 | @deffn primitive %allocate-instance class initargs | |
352 | Create a new instance of class @var{class} and initialize it | |
353 | from the arguments @var{initargs}. | |
354 | @end deffn | |
355 | ||
356 | @deffn primitive slot-exists? obj slot_name | |
357 | Return @code{#t} if @var{obj} has a slot named @var{slot_name}. | |
358 | @end deffn | |
359 | ||
360 | @deffn primitive slot-bound? obj slot_name | |
361 | Return @code{#t} if the slot named @var{slot_name} of @var{obj} | |
362 | is bound. | |
363 | @end deffn | |
364 | ||
365 | @deffn primitive slot-set! obj slot_name value | |
366 | Set the slot named @var{slot_name} of @var{obj} to @var{value}. | |
367 | @end deffn | |
368 | ||
369 | @deffn primitive slot-exists-using-class? class obj slot_name | |
370 | @end deffn | |
371 | ||
372 | @deffn primitive slot-bound-using-class? class obj slot_name | |
373 | @end deffn | |
374 | ||
375 | @deffn primitive %fast-slot-set! obj index value | |
376 | Set the slot with index @var{index} in @var{obj} to | |
377 | @var{value}. | |
378 | @end deffn | |
379 | ||
380 | @deffn primitive %fast-slot-ref obj index | |
381 | Return the slot value with index @var{index} from @var{obj}. | |
382 | @end deffn | |
383 | ||
384 | @deffn primitive @@assert-bound-ref obj index | |
385 | Like @code{assert-bound}, but use @var{index} for accessing | |
386 | the value from @var{obj}. | |
387 | @end deffn | |
388 | ||
389 | @deffn primitive assert-bound value obj | |
390 | Return @var{value} if it is bound, and invoke the | |
391 | @var{slot-unbound} method of @var{obj} if it is not. | |
392 | @end deffn | |
393 | ||
394 | @deffn primitive unbound? obj | |
395 | Return @code{#t} if @var{obj} is unbound. | |
396 | @end deffn | |
397 | ||
398 | @deffn primitive make-unbound | |
399 | Return the unbound value. | |
400 | @end deffn | |
401 | ||
402 | @deffn primitive accessor-method-slot-definition obj | |
403 | Return the slot definition of the accessor @var{obj}. | |
404 | @end deffn | |
405 | ||
406 | @deffn primitive method-procedure obj | |
407 | Return the procedure of the method @var{obj}. | |
408 | @end deffn | |
409 | ||
410 | @deffn primitive method-specializers obj | |
411 | Return specializers of the method @var{obj}. | |
412 | @end deffn | |
413 | ||
414 | @deffn primitive method-generic-function obj | |
415 | Return the generic function fot the method @var{obj}. | |
416 | @end deffn | |
417 | ||
418 | @deffn primitive generic-function-methods obj | |
419 | Return the methods of the generic function @var{obj}. | |
420 | @end deffn | |
421 | ||
422 | @deffn primitive generic-function-name obj | |
423 | Return the name of the generic function @var{obj}. | |
424 | @end deffn | |
425 | ||
426 | @deffn primitive class-environment obj | |
427 | Return the environment of the class @var{obj}. | |
428 | @end deffn | |
429 | ||
430 | @deffn primitive class-slots obj | |
431 | Return the slot list of the class @var{obj}. | |
432 | @end deffn | |
433 | ||
434 | @deffn primitive class-precedence-list obj | |
435 | Return the class precedence list of the class @var{obj}. | |
436 | @end deffn | |
437 | ||
438 | @deffn primitive class-direct-methods obj | |
439 | Return the direct methods of the class @var{obj} | |
440 | @end deffn | |
441 | ||
442 | @deffn primitive class-direct-subclasses obj | |
443 | Return the direct subclasses of the class @var{obj}. | |
444 | @end deffn | |
445 | ||
446 | @deffn primitive class-direct-slots obj | |
447 | Return the direct slots of the class @var{obj}. | |
448 | @end deffn | |
449 | ||
450 | @deffn primitive class-direct-supers obj | |
451 | Return the direct superclasses of the class @var{obj}. | |
452 | @end deffn | |
453 | ||
454 | @deffn primitive class-name obj | |
455 | Return the class name of @var{obj}. | |
456 | @end deffn | |
457 | ||
458 | @deffn primitive instance? obj | |
459 | Return @code{#t} if @var{obj} is an instance. | |
460 | @end deffn | |
461 | ||
462 | @deffn primitive %inherit-magic! class dsupers | |
463 | @end deffn | |
464 | ||
465 | @deffn primitive %prep-layout! class | |
466 | @end deffn | |
467 | ||
468 | @deffn primitive %initialize-object obj initargs | |
469 | Initialize the object @var{obj} with the given arguments | |
470 | @var{initargs}. | |
471 | @end deffn | |
472 | ||
473 | @deffn primitive make . args | |
474 | Make a new object. @var{args} must contain the class and | |
475 | all necessary initialization information. | |
476 | @end deffn | |
477 | ||
478 | @deffn primitive slot-ref obj slot_name | |
479 | Return the value from @var{obj}'s slot with the name | |
480 | @var{slot_name}. | |
481 | @end deffn | |
482 | ||
483 | @deffn primitive builtin-bindings | |
484 | Create and return a copy of the global symbol table, removing all | |
485 | unbound symbols. | |
486 | @end deffn | |
487 | ||
488 | @deffn primitive %tag-body body | |
489 | Internal GOOPS magic---don't use this function! | |
490 | @end deffn | |
491 | ||
492 | @deffn primitive list* | |
493 | scm_cons_star | |
494 | @end deffn | |
495 | ||
496 | @deffn primitive set-current-module module | |
497 | Set the current module to @var{module} and return | |
498 | the previous current module. | |
499 | @end deffn | |
500 | ||
501 | @deffn primitive current-module | |
502 | Return the current module. | |
503 | @end deffn | |
504 | ||
505 | @deffn primitive c-clear-registered-modules | |
506 | Destroy the list of modules registered with the current Guile process. | |
507 | The return value is unspecified. @strong{Warning:} this function does | |
508 | not actually unlink or deallocate these modules, but only destroys the | |
509 | records of which modules have been loaded. It should therefore be used | |
510 | only by module bookkeeping operations. | |
511 | @end deffn | |
512 | ||
513 | @deffn primitive c-registered-modules | |
514 | Return a list of the object code modules that have been imported into | |
515 | the current Guile process. Each element of the list is a pair whose | |
516 | car is the name of the module, and whose cdr is the function handle | |
517 | for that module's initializer function. The name is the string that | |
518 | has been passed to scm_register_module_xxx. | |
519 | @end deffn | |
520 | ||
521 | @deffn primitive include-deprecated-features | |
522 | Return @code{#t} iff deprecated features should be included | |
523 | in public interfaces. | |
524 | @end deffn | |
525 | ||
526 | @deffn primitive issue-deprecation-warning . msgs | |
527 | Output @var{msgs} to @code{(current-error-port)} when this | |
528 | is the first call to @code{issue-deprecation-warning} with | |
529 | this specific @var{msg}. Do nothing otherwise. | |
530 | The argument @var{msgs} should be a list of strings; | |
531 | they are printed in turn, each one followed by a newline. | |
532 | @end deffn |