guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symbol vs. Value Question


From: Marius Vollmer
Subject: Re: Symbol vs. Value Question
Date: 20 Oct 2001 13:38:47 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Keith Wright <address@hidden> writes:

> guile> (define xxx '(not for children))
> guile> (eval 'xxx (interaction-environment))
> (not for children)
> 
> This works, but it's still the wrong direction.  If you want the
> value back, put it in a variable, not a symbol.

Doing symbol/variable lookup from C is considered an `advanced' topic.
If you can avoid it, avoid it.  It is usually better just to pass
concrete objects to C functions and leave all the lookup stuff to the
Scheme side.

It is difficult to mirror the Scheme variable semantics from C since
you don't get all the necessary information about the environment that
a particular piece of Scheme code is executing it.  Just from being
called from Scheme does not give you access to the lexical environment
of the calling code, or even its top-level module.

>From C, you can generally only inspect top-level bindings, relative to
some module.  The `(current-module)' is sometimes but not always the
right module for this.  In a module you can find a mapping from
symbols to variables.  Each variable contains a value that you can
read and maybe modify.  Use scm_module_lookup and scm_module_define
for these operations.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]