*** empty log message ***
[bpt/guile.git] / doc / ref / new-docstrings.texi
CommitLineData
a0e07ba4
NJ
1
2@c module (guile)
3
4@deffn primitive environment? obj
5Return @code{#t} if @var{obj} is an environment, or @code{#f}
6otherwise.
7@end deffn
8
9@deffn primitive environment-bound? env sym
10Return @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
15Return 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
21Iterate over all the bindings in @var{env}, accumulating some
22value.
23For each binding in @var{env}, apply @var{proc} to the symbol
24bound, its value, and the result from the previous application
25of @var{proc}.
26Use @var{init} as @var{proc}'s third argument the first time
27@var{proc} is applied.
28If @var{env} contains no bindings, this function simply returns
29@var{init}.
30If @var{env} binds the symbol sym1 to the value val1, sym2 to
31val2, 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
39Each binding in @var{env} will be processed exactly once.
40@code{environment-fold} makes no guarantees about the order in
41which the bindings are processed.
42Here is a function which, given an environment, constructs an
43association list representing that environment's bindings,
44using 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
55Bind @var{sym} to a new location containing @var{val} in
56@var{env}. If @var{sym} is already bound to another location
57in @var{env} and the binding is mutable, that binding is
58replaced. The new binding and location are both mutable. The
59return value is unspecified.
60If @var{sym} is already bound in @var{env}, and the binding is
61immutable, signal an @code{environment:immutable-binding} error.
62@end deffn
63
64@deffn primitive environment-undefine env sym
65Remove any binding for @var{sym} from @var{env}. If @var{sym}
66is unbound in @var{env}, do nothing. The return value is
67unspecified.
68If @var{sym} is already bound in @var{env}, and the binding is
69immutable, signal an @code{environment:immutable-binding} error.
70@end deffn
71
72@deffn primitive environment-set! env sym val
73If @var{env} binds @var{sym} to some location, change that
74location's value to @var{val}. The return value is
75unspecified.
76If @var{sym} is not bound in @var{env}, signal an
77@code{environment:unbound} error. If @var{env} binds @var{sym}
78to an immutable location, signal an
79@code{environment:immutable-location} error.
80@end deffn
81
82@deffn primitive environment-cell env sym for_write
83Return the value cell which @var{env} binds to @var{sym}, or
84@code{#f} if the binding does not live in a value cell.
85The argument @var{for-write} indicates whether the caller
86intends to modify the variable's value by mutating the value
87cell. If the variable is immutable, then
88@code{environment-cell} signals an
89@code{environment:immutable-location} error.
90If @var{sym} is unbound in @var{env}, signal an
91@code{environment:unbound} error.
92If you use this function, you should consider using
93@code{environment-observe}, to be notified when @var{sym} gets
94re-bound to a new value cell, or becomes undefined.
95@end deffn
96
97@deffn primitive environment-observe env proc
98Whenever @var{env}'s bindings change, apply @var{proc} to
99@var{env}.
100This function returns an object, token, which you can pass to
101@code{environment-unobserve} to remove @var{proc} from the set
102of procedures observing @var{env}. The type and value of
103token is unspecified.
104@end deffn
105
106@deffn primitive environment-observe-weak env proc
107This function is the same as environment-observe, except that
108the reference @var{env} retains to @var{proc} is a weak
109reference. This means that, if there are no other live,
110non-weak references to @var{proc}, it will be
111garbage-collected, and dropped from @var{env}'s
112list of observing procedures.
113@end deffn
114
115@deffn primitive environment-unobserve token
116Cancel the observation request which returned the value
117@var{token}. The return value is unspecified.
118If a call @code{(environment-observe env proc)} returns
119@var{token}, then the call @code{(environment-unobserve token)}
120will cause @var{proc} to no longer be called when @var{env}'s
121bindings change.
122@end deffn
123
124@deffn primitive make-leaf-environment
125Create a new leaf environment, containing no bindings.
126All bindings and locations created in the new environment
127will be mutable.
128@end deffn
129
130@deffn primitive leaf-environment? object
131Return @code{#t} if object is a leaf environment, or @code{#f}
132otherwise.
133@end deffn
134
135@deffn primitive make-eval-environment local imported
136Return a new environment object eval whose bindings are the
137union of the bindings in the environments @var{local} and
138@var{imported}, with bindings from @var{local} taking
139precedence. Definitions made in eval are placed in @var{local}.
140Applying @code{environment-define} or
141@code{environment-undefine} to eval has the same effect as
142applying the procedure to @var{local}.
143Note that eval incorporates @var{local} and @var{imported} by
144reference:
145If, after creating eval, the program changes the bindings of
146@var{local} or @var{imported}, those changes will be visible
147in eval.
148Since most Scheme evaluation takes place in eval environments,
149they transparently cache the bindings received from @var{local}
150and @var{imported}. Thus, the first time the program looks up
151a symbol in eval, eval may make calls to @var{local} or
152@var{imported} to find their bindings, but subsequent
153references to that symbol will be as fast as references to
154bindings in finite environments.
155In 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
160Return @code{#t} if object is an eval environment, or @code{#f}
161otherwise.
162@end deffn
163
164@deffn primitive eval-environment-local env
165Return the local environment of eval environment @var{env}.
166@end deffn
167
168@deffn primitive eval-environment-set-local! env local
169Change @var{env}'s local environment to @var{local}.
170@end deffn
171
172@deffn primitive eval-environment-imported env
173Return the imported environment of eval environment @var{env}.
174@end deffn
175
176@deffn primitive eval-environment-set-imported! env imported
177Change @var{env}'s imported environment to @var{imported}.
178@end deffn
179
180@deffn primitive make-import-environment imports conflict_proc
181Return a new environment @var{imp} whose bindings are the union
182of 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.
186If two different elements of @var{imports} have a binding for
187the same symbol, the @var{conflict-proc} is called with the
188following parameters: the import environment, the symbol and
189the list of the imported environments that bind the symbol.
190If the @var{conflict-proc} returns an environment @var{env},
191the conflict is considered as resolved and the binding from
192@var{env} is used. If the @var{conflict-proc} returns some
193non-environment object, the conflict is considered unresolved
194and the symbol is treated as unspecified in the import
195environment.
196The checking for conflicts may be performed lazily, i. e. at
197the moment when a value or binding for a certain symbol is
198requested instead of the moment when the environment is
199created or the bindings of the imports change.
200All 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,
204notice that the set of bindings in @var{imp} may still change,
205if one of its imported environments changes.
206@end deffn
207
208@deffn primitive import-environment? object
209Return @code{#t} if object is an import environment, or
210@code{#f} otherwise.
211@end deffn
212
213@deffn primitive import-environment-imports env
214Return the list of environments imported by the import
215environment @var{env}.
216@end deffn
217
218@deffn primitive import-environment-set-imports! env imports
219Change @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
224Return a new environment @var{exp} containing only those
225bindings in private whose symbols are present in
226@var{signature}. The @var{private} argument must be an
227environment.
228
229The 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 ...)
236where 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
254It is an error for an element of signature to specify both
255@code{mutable-location} and @code{immutable-location}. If
256neither is specified, @code{immutable-location} is assumed.
257
258As a special case, if an element of signature is a lone
259symbol @var{sym}, it is equivalent to an element of the form
260@code{(sym)}.
261
262All 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,
266notice that the set of bindings in @var{exp} may still change,
267if the bindings in private change.
268@end deffn
269
270@deffn primitive export-environment? object
271Return @code{#t} if object is an export environment, or
272@code{#f} otherwise.
273@end deffn
274
275@deffn primitive export-environment-private env
276Return the private environment of export environment @var{env}.
277@end deffn
278
279@deffn primitive export-environment-set-private! env private
280Change the private environment of export environment @var{env}.
281@end deffn
282
283@deffn primitive export-environment-signature env
284Return the signature of export environment @var{env}.
285@end deffn
286
287@deffn primitive export-environment-set-signature! env signature
288Change the signature of export environment @var{env}.
289@end deffn
290
291@deffn primitive %compute-slots class
292Return a list consisting of the names of all slots belonging to
293class @var{class}, i. e. the slots of @var{class} and of all of
294its superclasses.
295@end deffn
296
297@deffn primitive get-keyword key l default_value
298Determine an associated value for the keyword @var{key} from
299the list @var{l}. The list @var{l} has to consist of an even
300number of elements, where, starting with the first, every
301second element is a keyword, followed by its associated value.
302If @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
9401323e 307
a0e07ba4
NJ
308@end deffn
309
310@deffn primitive slot-set-using-class! class obj slot_name value
9401323e 311
a0e07ba4
NJ
312@end deffn
313
314@deffn primitive class-of x
315Return the class of @var{x}.
316@end deffn
317
318@deffn primitive %goops-loaded
319Announce that GOOPS is loaded and perform initialization
320on the C level which depends on the loaded GOOPS modules.
321@end deffn
322
323@deffn primitive %method-more-specific? m1 m2 targs
9401323e 324
a0e07ba4
NJ
325@end deffn
326
327@deffn primitive find-method . l
9401323e 328
a0e07ba4
NJ
329@end deffn
330
331@deffn primitive primitive-generic-generic subr
9401323e 332
a0e07ba4
NJ
333@end deffn
334
335@deffn primitive enable-primitive-generic! . subrs
9401323e 336
a0e07ba4
NJ
337@end deffn
338
339@deffn primitive generic-capability? proc
9401323e 340
a0e07ba4
NJ
341@end deffn
342
343@deffn primitive %invalidate-method-cache! gf
9401323e 344
a0e07ba4
NJ
345@end deffn
346
347@deffn primitive %invalidate-class class
9401323e 348
a0e07ba4
NJ
349@end deffn
350
351@deffn primitive %modify-class old new
9401323e 352
a0e07ba4
NJ
353@end deffn
354
355@deffn primitive %modify-instance old new
9401323e 356
a0e07ba4
NJ
357@end deffn
358
359@deffn primitive %set-object-setter! obj setter
9401323e 360
a0e07ba4
NJ
361@end deffn
362
363@deffn primitive %allocate-instance class initargs
364Create a new instance of class @var{class} and initialize it
365from the arguments @var{initargs}.
366@end deffn
367
368@deffn primitive slot-exists? obj slot_name
369Return @code{#t} if @var{obj} has a slot named @var{slot_name}.
370@end deffn
371
372@deffn primitive slot-bound? obj slot_name
373Return @code{#t} if the slot named @var{slot_name} of @var{obj}
374is bound.
375@end deffn
376
377@deffn primitive slot-set! obj slot_name value
378Set the slot named @var{slot_name} of @var{obj} to @var{value}.
379@end deffn
380
381@deffn primitive slot-exists-using-class? class obj slot_name
9401323e 382
a0e07ba4
NJ
383@end deffn
384
385@deffn primitive slot-bound-using-class? class obj slot_name
9401323e 386
a0e07ba4
NJ
387@end deffn
388
389@deffn primitive %fast-slot-set! obj index value
390Set the slot with index @var{index} in @var{obj} to
391@var{value}.
392@end deffn
393
394@deffn primitive %fast-slot-ref obj index
395Return the slot value with index @var{index} from @var{obj}.
396@end deffn
397
398@deffn primitive @@assert-bound-ref obj index
399Like @code{assert-bound}, but use @var{index} for accessing
400the value from @var{obj}.
401@end deffn
402
403@deffn primitive assert-bound value obj
404Return @var{value} if it is bound, and invoke the
405@var{slot-unbound} method of @var{obj} if it is not.
406@end deffn
407
408@deffn primitive unbound? obj
409Return @code{#t} if @var{obj} is unbound.
410@end deffn
411
412@deffn primitive make-unbound
413Return the unbound value.
414@end deffn
415
416@deffn primitive accessor-method-slot-definition obj
417Return the slot definition of the accessor @var{obj}.
418@end deffn
419
420@deffn primitive method-procedure obj
421Return the procedure of the method @var{obj}.
422@end deffn
423
424@deffn primitive method-specializers obj
425Return specializers of the method @var{obj}.
426@end deffn
427
428@deffn primitive method-generic-function obj
429Return the generic function fot the method @var{obj}.
430@end deffn
431
432@deffn primitive generic-function-methods obj
433Return the methods of the generic function @var{obj}.
434@end deffn
435
436@deffn primitive generic-function-name obj
437Return the name of the generic function @var{obj}.
438@end deffn
439
440@deffn primitive class-environment obj
441Return the environment of the class @var{obj}.
442@end deffn
443
444@deffn primitive class-slots obj
445Return the slot list of the class @var{obj}.
446@end deffn
447
448@deffn primitive class-precedence-list obj
449Return the class precedence list of the class @var{obj}.
450@end deffn
451
452@deffn primitive class-direct-methods obj
453Return the direct methods of the class @var{obj}
454@end deffn
455
456@deffn primitive class-direct-subclasses obj
457Return the direct subclasses of the class @var{obj}.
458@end deffn
459
460@deffn primitive class-direct-slots obj
461Return the direct slots of the class @var{obj}.
462@end deffn
463
464@deffn primitive class-direct-supers obj
465Return the direct superclasses of the class @var{obj}.
466@end deffn
467
468@deffn primitive class-name obj
469Return the class name of @var{obj}.
470@end deffn
471
472@deffn primitive instance? obj
473Return @code{#t} if @var{obj} is an instance.
474@end deffn
475
476@deffn primitive %inherit-magic! class dsupers
9401323e 477
a0e07ba4
NJ
478@end deffn
479
480@deffn primitive %prep-layout! class
9401323e 481
a0e07ba4
NJ
482@end deffn
483
484@deffn primitive %initialize-object obj initargs
485Initialize the object @var{obj} with the given arguments
486@var{initargs}.
487@end deffn
488
489@deffn primitive make . args
490Make a new object. @var{args} must contain the class and
491all necessary initialization information.
492@end deffn
493
494@deffn primitive slot-ref obj slot_name
495Return the value from @var{obj}'s slot with the name
496@var{slot_name}.
497@end deffn
498
499@deffn primitive builtin-bindings
500Create and return a copy of the global symbol table, removing all
501unbound symbols.
502@end deffn
503
504@deffn primitive %tag-body body
505Internal GOOPS magic---don't use this function!
506@end deffn
507
508@deffn primitive list*
509scm_cons_star
510@end deffn
511
512@deffn primitive set-current-module module
513Set the current module to @var{module} and return
514the previous current module.
515@end deffn
516
517@deffn primitive current-module
518Return the current module.
519@end deffn
520
521@deffn primitive c-clear-registered-modules
522Destroy the list of modules registered with the current Guile process.
523The return value is unspecified. @strong{Warning:} this function does
524not actually unlink or deallocate these modules, but only destroys the
525records of which modules have been loaded. It should therefore be used
526only by module bookkeeping operations.
527@end deffn
528
529@deffn primitive c-registered-modules
530Return a list of the object code modules that have been imported into
531the current Guile process. Each element of the list is a pair whose
532car is the name of the module, and whose cdr is the function handle
533for that module's initializer function. The name is the string that
534has been passed to scm_register_module_xxx.
535@end deffn
536
537@deffn primitive include-deprecated-features
538Return @code{#t} iff deprecated features should be included
539in public interfaces.
540@end deffn
541
542@deffn primitive issue-deprecation-warning . msgs
543Output @var{msgs} to @code{(current-error-port)} when this
544is the first call to @code{issue-deprecation-warning} with
545this specific @var{msg}. Do nothing otherwise.
546The argument @var{msgs} should be a list of strings;
547they are printed in turn, each one followed by a newline.
548@end deffn
9401323e
NJ
549
550@deffn primitive valid-object-procedure? proc
551Return @code{#t} iff @var{proc} is a procedure that can be used with @code{set-object-procedure}. It is always valid to use a closure constructed by @code{lambda}.
552@end deffn
553
554@deffn primitive %get-pre-modules-obarray
555Return the obarray that is used for all new bindings before the module system is booted. The first call to @code{set-current-module} will boot the module system.
556@end deffn
557
558@deffn primitive standard-interface-eval-closure module
559Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added.
560@end deffn
561
562@deffn primitive env-module env
563Return the module of @var{ENV}, a lexical environment.
564@end deffn
565
566@deffn primitive load-extension lib init
567Load and initilize the extension designated by LIB and INIT.
568When there is no pre-registered function for LIB/INIT, this is
569equivalent to
570
571@lisp
572(dynamic-call INIT (dynamic-link LIB))
573@end lisp
574
575When there is a pre-registered function, that function is called
576instead.
577
578Normally, there is no pre-registered function. This option exists
579only for situations where dynamic linking is unavailable or unwanted.
580In that case, you would statically link your program with the desired
581library, and register its init function right after Guile has been
582initialized.
583
584LIB should be a string denoting a shared library without any file type
585suffix such as ".so". The suffix is provided automatically. It
586should also not contain any directory components. Libraries that
587implement Guile Extensions should be put into the normal locations for
588shared libraries. We recommend to use the naming convention
589libguile-bla-blum for a extension related to a module `(bla blum)'.
590
591The normal way for a extension to be used is to write a small Scheme
592file that defines a module, and to load the extension into this
593module. When the module is auto-loaded, the extension is loaded as
594well. For example,
595
596@lisp
597(define-module (bla blum))
598
599(load-extension "libguile-bla-blum" "bla_init_blum")
600@end lisp
601@end deffn