* Organize documentation into per-manual directories (halfway point commit).
[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
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
313Return the class of @var{x}.
314@end deffn
315
316@deffn primitive %goops-loaded
317Announce that GOOPS is loaded and perform initialization
318on 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
352Create a new instance of class @var{class} and initialize it
353from the arguments @var{initargs}.
354@end deffn
355
356@deffn primitive slot-exists? obj slot_name
357Return @code{#t} if @var{obj} has a slot named @var{slot_name}.
358@end deffn
359
360@deffn primitive slot-bound? obj slot_name
361Return @code{#t} if the slot named @var{slot_name} of @var{obj}
362is bound.
363@end deffn
364
365@deffn primitive slot-set! obj slot_name value
366Set 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
376Set 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
381Return the slot value with index @var{index} from @var{obj}.
382@end deffn
383
384@deffn primitive @@assert-bound-ref obj index
385Like @code{assert-bound}, but use @var{index} for accessing
386the value from @var{obj}.
387@end deffn
388
389@deffn primitive assert-bound value obj
390Return @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
395Return @code{#t} if @var{obj} is unbound.
396@end deffn
397
398@deffn primitive make-unbound
399Return the unbound value.
400@end deffn
401
402@deffn primitive accessor-method-slot-definition obj
403Return the slot definition of the accessor @var{obj}.
404@end deffn
405
406@deffn primitive method-procedure obj
407Return the procedure of the method @var{obj}.
408@end deffn
409
410@deffn primitive method-specializers obj
411Return specializers of the method @var{obj}.
412@end deffn
413
414@deffn primitive method-generic-function obj
415Return the generic function fot the method @var{obj}.
416@end deffn
417
418@deffn primitive generic-function-methods obj
419Return the methods of the generic function @var{obj}.
420@end deffn
421
422@deffn primitive generic-function-name obj
423Return the name of the generic function @var{obj}.
424@end deffn
425
426@deffn primitive class-environment obj
427Return the environment of the class @var{obj}.
428@end deffn
429
430@deffn primitive class-slots obj
431Return the slot list of the class @var{obj}.
432@end deffn
433
434@deffn primitive class-precedence-list obj
435Return the class precedence list of the class @var{obj}.
436@end deffn
437
438@deffn primitive class-direct-methods obj
439Return the direct methods of the class @var{obj}
440@end deffn
441
442@deffn primitive class-direct-subclasses obj
443Return the direct subclasses of the class @var{obj}.
444@end deffn
445
446@deffn primitive class-direct-slots obj
447Return the direct slots of the class @var{obj}.
448@end deffn
449
450@deffn primitive class-direct-supers obj
451Return the direct superclasses of the class @var{obj}.
452@end deffn
453
454@deffn primitive class-name obj
455Return the class name of @var{obj}.
456@end deffn
457
458@deffn primitive instance? obj
459Return @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
469Initialize the object @var{obj} with the given arguments
470@var{initargs}.
471@end deffn
472
473@deffn primitive make . args
474Make a new object. @var{args} must contain the class and
475all necessary initialization information.
476@end deffn
477
478@deffn primitive slot-ref obj slot_name
479Return the value from @var{obj}'s slot with the name
480@var{slot_name}.
481@end deffn
482
483@deffn primitive builtin-bindings
484Create and return a copy of the global symbol table, removing all
485unbound symbols.
486@end deffn
487
488@deffn primitive %tag-body body
489Internal GOOPS magic---don't use this function!
490@end deffn
491
492@deffn primitive list*
493scm_cons_star
494@end deffn
495
496@deffn primitive set-current-module module
497Set the current module to @var{module} and return
498the previous current module.
499@end deffn
500
501@deffn primitive current-module
502Return the current module.
503@end deffn
504
505@deffn primitive c-clear-registered-modules
506Destroy the list of modules registered with the current Guile process.
507The return value is unspecified. @strong{Warning:} this function does
508not actually unlink or deallocate these modules, but only destroys the
509records of which modules have been loaded. It should therefore be used
510only by module bookkeeping operations.
511@end deffn
512
513@deffn primitive c-registered-modules
514Return a list of the object code modules that have been imported into
515the current Guile process. Each element of the list is a pair whose
516car is the name of the module, and whose cdr is the function handle
517for that module's initializer function. The name is the string that
518has been passed to scm_register_module_xxx.
519@end deffn
520
521@deffn primitive include-deprecated-features
522Return @code{#t} iff deprecated features should be included
523in public interfaces.
524@end deffn
525
526@deffn primitive issue-deprecation-warning . msgs
527Output @var{msgs} to @code{(current-error-port)} when this
528is the first call to @code{issue-deprecation-warning} with
529this specific @var{msg}. Do nothing otherwise.
530The argument @var{msgs} should be a list of strings;
531they are printed in turn, each one followed by a newline.
532@end deffn