4 @deffn {Scheme Procedure} environment? obj
5 @deffnx {C Function} scm_environment_p (obj)
6 Return @code{#t} if @var{obj} is an environment, or @code{#f}
10 @deffn {Scheme Procedure} environment-bound? env sym
11 @deffnx {C Function} scm_environment_bound_p (env, sym)
12 Return @code{#t} if @var{sym} is bound in @var{env}, or
16 @deffn {Scheme Procedure} environment-ref env sym
17 @deffnx {C Function} scm_environment_ref (env, sym)
18 Return the value of the location bound to @var{sym} in
19 @var{env}. If @var{sym} is unbound in @var{env}, signal an
20 @code{environment:unbound} error.
23 @deffn {Scheme Procedure} environment-fold env proc init
24 @deffnx {C Function} scm_environment_fold (env, proc, init)
25 Iterate over all the bindings in @var{env}, accumulating some
27 For each binding in @var{env}, apply @var{proc} to the symbol
28 bound, its value, and the result from the previous application
30 Use @var{init} as @var{proc}'s third argument the first time
31 @var{proc} is applied.
32 If @var{env} contains no bindings, this function simply returns
34 If @var{env} binds the symbol sym1 to the value val1, sym2 to
35 val2, and so on, then this procedure computes:
43 Each binding in @var{env} will be processed exactly once.
44 @code{environment-fold} makes no guarantees about the order in
45 which the bindings are processed.
46 Here is a function which, given an environment, constructs an
47 association list representing that environment's bindings,
48 using environment-fold:
50 (define (environment->alist env)
52 (lambda (sym val tail)
53 (cons (cons sym val) tail))
58 @deffn {Scheme Procedure} environment-define env sym val
59 @deffnx {C Function} scm_environment_define (env, sym, val)
60 Bind @var{sym} to a new location containing @var{val} in
61 @var{env}. If @var{sym} is already bound to another location
62 in @var{env} and the binding is mutable, that binding is
63 replaced. The new binding and location are both mutable. The
64 return value is unspecified.
65 If @var{sym} is already bound in @var{env}, and the binding is
66 immutable, signal an @code{environment:immutable-binding} error.
69 @deffn {Scheme Procedure} environment-undefine env sym
70 @deffnx {C Function} scm_environment_undefine (env, sym)
71 Remove any binding for @var{sym} from @var{env}. If @var{sym}
72 is unbound in @var{env}, do nothing. The return value is
74 If @var{sym} is already bound in @var{env}, and the binding is
75 immutable, signal an @code{environment:immutable-binding} error.
78 @deffn {Scheme Procedure} environment-set! env sym val
79 @deffnx {C Function} scm_environment_set_x (env, sym, val)
80 If @var{env} binds @var{sym} to some location, change that
81 location's value to @var{val}. The return value is
83 If @var{sym} is not bound in @var{env}, signal an
84 @code{environment:unbound} error. If @var{env} binds @var{sym}
85 to an immutable location, signal an
86 @code{environment:immutable-location} error.
89 @deffn {Scheme Procedure} environment-cell env sym for_write
90 @deffnx {C Function} scm_environment_cell (env, sym, for_write)
91 Return the value cell which @var{env} binds to @var{sym}, or
92 @code{#f} if the binding does not live in a value cell.
93 The argument @var{for-write} indicates whether the caller
94 intends to modify the variable's value by mutating the value
95 cell. If the variable is immutable, then
96 @code{environment-cell} signals an
97 @code{environment:immutable-location} error.
98 If @var{sym} is unbound in @var{env}, signal an
99 @code{environment:unbound} error.
100 If you use this function, you should consider using
101 @code{environment-observe}, to be notified when @var{sym} gets
102 re-bound to a new value cell, or becomes undefined.
105 @deffn {Scheme Procedure} environment-observe env proc
106 @deffnx {C Function} scm_environment_observe (env, proc)
107 Whenever @var{env}'s bindings change, apply @var{proc} to
109 This function returns an object, token, which you can pass to
110 @code{environment-unobserve} to remove @var{proc} from the set
111 of procedures observing @var{env}. The type and value of
112 token is unspecified.
115 @deffn {Scheme Procedure} environment-observe-weak env proc
116 @deffnx {C Function} scm_environment_observe_weak (env, proc)
117 This function is the same as environment-observe, except that
118 the reference @var{env} retains to @var{proc} is a weak
119 reference. This means that, if there are no other live,
120 non-weak references to @var{proc}, it will be
121 garbage-collected, and dropped from @var{env}'s
122 list of observing procedures.
125 @deffn {Scheme Procedure} environment-unobserve token
126 @deffnx {C Function} scm_environment_unobserve (token)
127 Cancel the observation request which returned the value
128 @var{token}. The return value is unspecified.
129 If a call @code{(environment-observe env proc)} returns
130 @var{token}, then the call @code{(environment-unobserve token)}
131 will cause @var{proc} to no longer be called when @var{env}'s
135 @deffn {Scheme Procedure} make-leaf-environment
136 @deffnx {C Function} scm_make_leaf_environment ()
137 Create a new leaf environment, containing no bindings.
138 All bindings and locations created in the new environment
142 @deffn {Scheme Procedure} leaf-environment? object
143 @deffnx {C Function} scm_leaf_environment_p (object)
144 Return @code{#t} if object is a leaf environment, or @code{#f}
148 @deffn {Scheme Procedure} make-eval-environment local imported
149 @deffnx {C Function} scm_make_eval_environment (local, imported)
150 Return a new environment object eval whose bindings are the
151 union of the bindings in the environments @var{local} and
152 @var{imported}, with bindings from @var{local} taking
153 precedence. Definitions made in eval are placed in @var{local}.
154 Applying @code{environment-define} or
155 @code{environment-undefine} to eval has the same effect as
156 applying the procedure to @var{local}.
157 Note that eval incorporates @var{local} and @var{imported} by
159 If, after creating eval, the program changes the bindings of
160 @var{local} or @var{imported}, those changes will be visible
162 Since most Scheme evaluation takes place in eval environments,
163 they transparently cache the bindings received from @var{local}
164 and @var{imported}. Thus, the first time the program looks up
165 a symbol in eval, eval may make calls to @var{local} or
166 @var{imported} to find their bindings, but subsequent
167 references to that symbol will be as fast as references to
168 bindings in finite environments.
169 In typical use, @var{local} will be a finite environment, and
170 @var{imported} will be an import environment
173 @deffn {Scheme Procedure} eval-environment? object
174 @deffnx {C Function} scm_eval_environment_p (object)
175 Return @code{#t} if object is an eval environment, or @code{#f}
179 @deffn {Scheme Procedure} eval-environment-local env
180 @deffnx {C Function} scm_eval_environment_local (env)
181 Return the local environment of eval environment @var{env}.
184 @deffn {Scheme Procedure} eval-environment-set-local! env local
185 @deffnx {C Function} scm_eval_environment_set_local_x (env, local)
186 Change @var{env}'s local environment to @var{local}.
189 @deffn {Scheme Procedure} eval-environment-imported env
190 @deffnx {C Function} scm_eval_environment_imported (env)
191 Return the imported environment of eval environment @var{env}.
194 @deffn {Scheme Procedure} eval-environment-set-imported! env imported
195 @deffnx {C Function} scm_eval_environment_set_imported_x (env, imported)
196 Change @var{env}'s imported environment to @var{imported}.
199 @deffn {Scheme Procedure} make-import-environment imports conflict_proc
200 @deffnx {C Function} scm_make_import_environment (imports, conflict_proc)
201 Return a new environment @var{imp} whose bindings are the union
202 of the bindings from the environments in @var{imports};
203 @var{imports} must be a list of environments. That is,
204 @var{imp} binds a symbol to a location when some element of
206 If two different elements of @var{imports} have a binding for
207 the same symbol, the @var{conflict-proc} is called with the
208 following parameters: the import environment, the symbol and
209 the list of the imported environments that bind the symbol.
210 If the @var{conflict-proc} returns an environment @var{env},
211 the conflict is considered as resolved and the binding from
212 @var{env} is used. If the @var{conflict-proc} returns some
213 non-environment object, the conflict is considered unresolved
214 and the symbol is treated as unspecified in the import
216 The checking for conflicts may be performed lazily, i. e. at
217 the moment when a value or binding for a certain symbol is
218 requested instead of the moment when the environment is
219 created or the bindings of the imports change.
220 All bindings in @var{imp} are immutable. If you apply
221 @code{environment-define} or @code{environment-undefine} to
222 @var{imp}, Guile will signal an
223 @code{environment:immutable-binding} error. However,
224 notice that the set of bindings in @var{imp} may still change,
225 if one of its imported environments changes.
228 @deffn {Scheme Procedure} import-environment? object
229 @deffnx {C Function} scm_import_environment_p (object)
230 Return @code{#t} if object is an import environment, or
234 @deffn {Scheme Procedure} import-environment-imports env
235 @deffnx {C Function} scm_import_environment_imports (env)
236 Return the list of environments imported by the import
237 environment @var{env}.
240 @deffn {Scheme Procedure} import-environment-set-imports! env imports
241 @deffnx {C Function} scm_import_environment_set_imports_x (env, imports)
242 Change @var{env}'s list of imported environments to
243 @var{imports}, and check for conflicts.
246 @deffn {Scheme Procedure} make-export-environment private signature
247 @deffnx {C Function} scm_make_export_environment (private, signature)
248 Return a new environment @var{exp} containing only those
249 bindings in private whose symbols are present in
250 @var{signature}. The @var{private} argument must be an
253 The environment @var{exp} binds symbol to location when
254 @var{env} does, and symbol is exported by @var{signature}.
256 @var{signature} is a list specifying which of the bindings in
257 @var{private} should be visible in @var{exp}. Each element of
258 @var{signature} should be a list of the form:
259 (symbol attribute ...)
260 where each attribute is one of the following:
262 @item the symbol @code{mutable-location}
263 @var{exp} should treat the
264 location bound to symbol as mutable. That is, @var{exp}
265 will pass calls to @code{environment-set!} or
266 @code{environment-cell} directly through to private.
267 @item the symbol @code{immutable-location}
268 @var{exp} should treat
269 the location bound to symbol as immutable. If the program
270 applies @code{environment-set!} to @var{exp} and symbol, or
271 calls @code{environment-cell} to obtain a writable value
272 cell, @code{environment-set!} will signal an
273 @code{environment:immutable-location} error. Note that, even
274 if an export environment treats a location as immutable, the
275 underlying environment may treat it as mutable, so its
278 It is an error for an element of signature to specify both
279 @code{mutable-location} and @code{immutable-location}. If
280 neither is specified, @code{immutable-location} is assumed.
282 As a special case, if an element of signature is a lone
283 symbol @var{sym}, it is equivalent to an element of the form
286 All bindings in @var{exp} are immutable. If you apply
287 @code{environment-define} or @code{environment-undefine} to
288 @var{exp}, Guile will signal an
289 @code{environment:immutable-binding} error. However,
290 notice that the set of bindings in @var{exp} may still change,
291 if the bindings in private change.
294 @deffn {Scheme Procedure} export-environment? object
295 @deffnx {C Function} scm_export_environment_p (object)
296 Return @code{#t} if object is an export environment, or
300 @deffn {Scheme Procedure} export-environment-private env
301 @deffnx {C Function} scm_export_environment_private (env)
302 Return the private environment of export environment @var{env}.
305 @deffn {Scheme Procedure} export-environment-set-private! env private
306 @deffnx {C Function} scm_export_environment_set_private_x (env, private)
307 Change the private environment of export environment @var{env}.
310 @deffn {Scheme Procedure} export-environment-signature env
311 @deffnx {C Function} scm_export_environment_signature (env)
312 Return the signature of export environment @var{env}.
315 @deffn {Scheme Procedure} export-environment-set-signature! env signature
316 @deffnx {C Function} scm_export_environment_set_signature_x (env, signature)
317 Change the signature of export environment @var{env}.
320 @deffn {Scheme Procedure} %compute-slots class
321 @deffnx {C Function} scm_sys_compute_slots (class)
322 Return a list consisting of the names of all slots belonging to
323 class @var{class}, i. e. the slots of @var{class} and of all of
327 @deffn {Scheme Procedure} get-keyword key l default_value
328 @deffnx {C Function} scm_get_keyword (key, l, default_value)
329 Determine an associated value for the keyword @var{key} from
330 the list @var{l}. The list @var{l} has to consist of an even
331 number of elements, where, starting with the first, every
332 second element is a keyword, followed by its associated value.
333 If @var{l} does not hold a value for @var{key}, the value
334 @var{default_value} is returned.
337 @deffn {Scheme Procedure} slot-ref-using-class class obj slot_name
338 @deffnx {C Function} scm_slot_ref_using_class (class, obj, slot_name)
342 @deffn {Scheme Procedure} slot-set-using-class! class obj slot_name value
343 @deffnx {C Function} scm_slot_set_using_class_x (class, obj, slot_name, value)
347 @deffn {Scheme Procedure} class-of x
348 @deffnx {C Function} scm_class_of (x)
349 Return the class of @var{x}.
352 @deffn {Scheme Procedure} %goops-loaded
353 @deffnx {C Function} scm_sys_goops_loaded ()
354 Announce that GOOPS is loaded and perform initialization
355 on the C level which depends on the loaded GOOPS modules.
358 @deffn {Scheme Procedure} %method-more-specific? m1 m2 targs
359 @deffnx {C Function} scm_sys_method_more_specific_p (m1, m2, targs)
363 @deffn {Scheme Procedure} find-method . l
364 @deffnx {C Function} scm_find_method (l)
368 @deffn {Scheme Procedure} primitive-generic-generic subr
369 @deffnx {C Function} scm_primitive_generic_generic (subr)
373 @deffn {Scheme Procedure} enable-primitive-generic! . subrs
374 @deffnx {C Function} scm_enable_primitive_generic_x (subrs)
378 @deffn {Scheme Procedure} generic-capability? proc
379 @deffnx {C Function} scm_generic_capability_p (proc)
383 @deffn {Scheme Procedure} %invalidate-method-cache! gf
384 @deffnx {C Function} scm_sys_invalidate_method_cache_x (gf)
388 @deffn {Scheme Procedure} %invalidate-class class
389 @deffnx {C Function} scm_sys_invalidate_class (class)
393 @deffn {Scheme Procedure} %modify-class old new
394 @deffnx {C Function} scm_sys_modify_class (old, new)
398 @deffn {Scheme Procedure} %modify-instance old new
399 @deffnx {C Function} scm_sys_modify_instance (old, new)
403 @deffn {Scheme Procedure} %set-object-setter! obj setter
404 @deffnx {C Function} scm_sys_set_object_setter_x (obj, setter)
408 @deffn {Scheme Procedure} %allocate-instance class initargs
409 @deffnx {C Function} scm_sys_allocate_instance (class, initargs)
410 Create a new instance of class @var{class} and initialize it
411 from the arguments @var{initargs}.
414 @deffn {Scheme Procedure} slot-exists? obj slot_name
415 @deffnx {C Function} scm_slots_exists_p (obj, slot_name)
416 Return @code{#t} if @var{obj} has a slot named @var{slot_name}.
419 @deffn {Scheme Procedure} slot-bound? obj slot_name
420 @deffnx {C Function} scm_slot_bound_p (obj, slot_name)
421 Return @code{#t} if the slot named @var{slot_name} of @var{obj}
425 @deffn {Scheme Procedure} slot-set! obj slot_name value
426 @deffnx {C Function} scm_slot_set_x (obj, slot_name, value)
427 Set the slot named @var{slot_name} of @var{obj} to @var{value}.
430 @deffn {Scheme Procedure} slot-exists-using-class? class obj slot_name
431 @deffnx {C Function} scm_slot_exists_using_class_p (class, obj, slot_name)
435 @deffn {Scheme Procedure} slot-bound-using-class? class obj slot_name
436 @deffnx {C Function} scm_slot_bound_using_class_p (class, obj, slot_name)
440 @deffn {Scheme Procedure} %fast-slot-set! obj index value
441 @deffnx {C Function} scm_sys_fast_slot_set_x (obj, index, value)
442 Set the slot with index @var{index} in @var{obj} to
446 @deffn {Scheme Procedure} %fast-slot-ref obj index
447 @deffnx {C Function} scm_sys_fast_slot_ref (obj, index)
448 Return the slot value with index @var{index} from @var{obj}.
451 @deffn {Scheme Procedure} @@assert-bound-ref obj index
452 @deffnx {C Function} scm_at_assert_bound_ref (obj, index)
453 Like @code{assert-bound}, but use @var{index} for accessing
454 the value from @var{obj}.
457 @deffn {Scheme Procedure} assert-bound value obj
458 @deffnx {C Function} scm_assert_bound (value, obj)
459 Return @var{value} if it is bound, and invoke the
460 @var{slot-unbound} method of @var{obj} if it is not.
463 @deffn {Scheme Procedure} unbound? obj
464 @deffnx {C Function} scm_unbound_p (obj)
465 Return @code{#t} if @var{obj} is unbound.
468 @deffn {Scheme Procedure} make-unbound
469 @deffnx {C Function} scm_make_unbound ()
470 Return the unbound value.
473 @deffn {Scheme Procedure} accessor-method-slot-definition obj
474 @deffnx {C Function} scm_accessor_method_slot_definition (obj)
475 Return the slot definition of the accessor @var{obj}.
478 @deffn {Scheme Procedure} method-procedure obj
479 @deffnx {C Function} scm_method_procedure (obj)
480 Return the procedure of the method @var{obj}.
483 @deffn {Scheme Procedure} method-specializers obj
484 @deffnx {C Function} scm_method_specializers (obj)
485 Return specializers of the method @var{obj}.
488 @deffn {Scheme Procedure} method-generic-function obj
489 @deffnx {C Function} scm_method_generic_function (obj)
490 Return the generic function for the method @var{obj}.
493 @deffn {Scheme Procedure} generic-function-methods obj
494 @deffnx {C Function} scm_generic_function_methods (obj)
495 Return the methods of the generic function @var{obj}.
498 @deffn {Scheme Procedure} generic-function-name obj
499 @deffnx {C Function} scm_generic_function_name (obj)
500 Return the name of the generic function @var{obj}.
503 @deffn {Scheme Procedure} class-environment obj
504 @deffnx {C Function} scm_class_environment (obj)
505 Return the environment of the class @var{obj}.
508 @deffn {Scheme Procedure} class-slots obj
509 @deffnx {C Function} scm_class_slots (obj)
510 Return the slot list of the class @var{obj}.
513 @deffn {Scheme Procedure} class-precedence-list obj
514 @deffnx {C Function} scm_class_precedence_list (obj)
515 Return the class precedence list of the class @var{obj}.
518 @deffn {Scheme Procedure} class-direct-methods obj
519 @deffnx {C Function} scm_class_direct_methods (obj)
520 Return the direct methods of the class @var{obj}
523 @deffn {Scheme Procedure} class-direct-subclasses obj
524 @deffnx {C Function} scm_class_direct_subclasses (obj)
525 Return the direct subclasses of the class @var{obj}.
528 @deffn {Scheme Procedure} class-direct-slots obj
529 @deffnx {C Function} scm_class_direct_slots (obj)
530 Return the direct slots of the class @var{obj}.
533 @deffn {Scheme Procedure} class-direct-supers obj
534 @deffnx {C Function} scm_class_direct_supers (obj)
535 Return the direct super-classes of the class @var{obj}.
538 @deffn {Scheme Procedure} class-name obj
539 @deffnx {C Function} scm_class_name (obj)
540 Return the class name of @var{obj}.
543 @deffn {Scheme Procedure} instance? obj
544 @deffnx {C Function} scm_instance_p (obj)
545 Return @code{#t} if @var{obj} is an instance.
548 @deffn {Scheme Procedure} %inherit-magic! class dsupers
549 @deffnx {C Function} scm_sys_inherit_magic_x (class, dsupers)
553 @deffn {Scheme Procedure} %prep-layout! class
554 @deffnx {C Function} scm_sys_prep_layout_x (class)
558 @deffn {Scheme Procedure} %initialize-object obj initargs
559 @deffnx {C Function} scm_sys_initialize_object (obj, initargs)
560 Initialize the object @var{obj} with the given arguments
564 @deffn {Scheme Procedure} make . args
565 @deffnx {C Function} scm_make (args)
566 Make a new object. @var{args} must contain the class and
567 all necessary initialization information.
570 @deffn {Scheme Procedure} slot-ref obj slot_name
571 @deffnx {C Function} scm_slot_ref (obj, slot_name)
572 Return the value from @var{obj}'s slot with the name
576 @deffn {Scheme Procedure} %tag-body body
577 @deffnx {C Function} scm_sys_tag_body (body)
578 Internal GOOPS magic---don't use this function!
581 @deffn {Scheme Procedure} list*
582 implemented by the C function "scm_cons_star"
585 @deffn {Scheme Procedure} set-current-module module
586 @deffnx {C Function} scm_set_current_module (module)
587 Set the current module to @var{module} and return
588 the previous current module.
591 @deffn {Scheme Procedure} current-module
592 @deffnx {C Function} scm_current_module ()
593 Return the current module.
596 @deffn {Scheme Procedure} c-clear-registered-modules
597 Destroy the list of modules registered with the current Guile process.
598 The return value is unspecified. @strong{Warning:} this function does
599 not actually unlink or deallocate these modules, but only destroys the
600 records of which modules have been loaded. It should therefore be used
601 only by module bookkeeping operations.
604 @deffn {Scheme Procedure} c-registered-modules
605 Return a list of the object code modules that have been imported into
606 the current Guile process. Each element of the list is a pair whose
607 car is the name of the module, and whose cdr is the function handle
608 for that module's initializer function. The name is the string that
609 has been passed to scm_register_module_xxx.
612 @deffn {Scheme Procedure} include-deprecated-features
613 Return @code{#t} iff deprecated features should be included
614 in public interfaces.
617 @deffn {Scheme Procedure} issue-deprecation-warning . msgs
618 Output @var{msgs} to @code{(current-error-port)} when this
619 is the first call to @code{issue-deprecation-warning} with
620 this specific @var{msg}. Do nothing otherwise.
621 The argument @var{msgs} should be a list of strings;
622 they are printed in turn, each one followed by a newline.
625 @deffn {Scheme Procedure} valid-object-procedure? proc
626 @deffnx {C Function} scm_valid_object_procedure_p (proc)
627 Return @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}.
630 @deffn {Scheme Procedure} %get-pre-modules-obarray
631 @deffnx {C Function} scm_get_pre_modules_obarray ()
632 Return 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.
635 @deffn {Scheme Procedure} standard-interface-eval-closure module
636 @deffnx {C Function} scm_standard_interface_eval_closure (module)
637 Return a interface eval closure for the module @var{module}. Such a closure does not allow new bindings to be added.
640 @deffn {Scheme Procedure} env-module env
641 @deffnx {C Function} scm_env_module (env)
642 Return the module of @var{ENV}, a lexical environment.
645 @deffn {Scheme Procedure} load-extension lib init
646 @deffnx {C Function} scm_load_extension (lib, init)
647 Load and initialize the extension designated by LIB and INIT.
648 When there is no pre-registered function for LIB/INIT, this is
652 (dynamic-call INIT (dynamic-link LIB))
655 When there is a pre-registered function, that function is called
658 Normally, there is no pre-registered function. This option exists
659 only for situations where dynamic linking is unavailable or unwanted.
660 In that case, you would statically link your program with the desired
661 library, and register its init function right after Guile has been
664 LIB should be a string denoting a shared library without any file type
665 suffix such as ".so". The suffix is provided automatically. It
666 should also not contain any directory components. Libraries that
667 implement Guile Extensions should be put into the normal locations for
668 shared libraries. We recommend to use the naming convention
669 libguile-bla-blum for a extension related to a module `(bla blum)'.
671 The normal way for a extension to be used is to write a small Scheme
672 file that defines a module, and to load the extension into this
673 module. When the module is auto-loaded, the extension is loaded as
677 (define-module (bla blum))
679 (load-extension "libguile-bla-blum" "bla_init_blum")