This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (lambda (foo) (some-c-function)) - can that C function get foo ?


On Wed, Jun 30, 1999 at 10:15:05PM +0200, Martin Baulig wrote:
> Hello guys,
> 
> This is a strange subject for this mail, but it's also some "strange"
> problem.

I could be wrong here by my way of thinking about the problem is that
an eval takes place within an environment, so effectively gh_eval_str()
grabs the default environment and uses that as the basis for the eval.
However, the let statement creates a closure which is quite different to
an environment. A closure says that foo is defined for that syntactical
grouping (i.e. inside the parens) and nowhere else. Closures are not
supposed to spread through function calls, they are not supposed to
spread at all, they stay exactly where they are defined.

Environments on the other hand can be passed around, which is why
they are more powerful and more dangerous.

For example, this won't work:

	(define (blerk) (display woggle))
	(let ((woggle "dooba")) (blerk))

and the problem is the same, unbound variable.
This is a schemey kind of thing and different to LISP.
You need this sort of thing for compilation because an environment
CANNOIT be compiled into the code, so you have no choice but to have
a lot of open-ended external references that get resolved each time
the code is executed (i.e. slow). On the other hand, a closure can
get compiled in (usually) and all references can be tied up except
the function args and any global vars.

	- Tel

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]