This is the mail archive of the guile@sources.redhat.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: variable binding


On Thu, Aug 24, 2000 at 12:59:13AM -0400, Keisuke Nishida wrote:
> 
> I guess Guile determines the binding of `+' when `foo' is first called,
> not when it is defined.  Also, it seems Guile overwrites the binding
> only at the first time `define' is called in a module:

Haskell exhibits a similar behavior. From the Haskell docs:

> Another way of explaining non-strict functions is that Haskell computes using
> definitions rather than the assignments found in traditional languages. Read a
> declaration such as 
>
> v                       = 1/0                 
>
> as `define v as 1/0' instead of `compute 1/0 and store the result in v'.
> Only if the value (definition) of v is needed will the division by zero error
> occur. By itself, this
> declaration does not imply any computation. Programming using assignments
> requires careful attention to the ordering of the assignments: the meaning
> of the program
> depends on the order in which the assignments are executed. Definitions,
> in contrast, are much simpler: they can be presented in any order without
> affecting the
> meaning of the program. 

(Sorry for the sloppy cut-n-paste job...)

I have read that in Scheme, multiple (consecutive) defines behave the same as a letrec. In order for letrec to work the bindings for the functions used therein must be computed after all the bindings that letrec makes have been made. Therefore, I think it's probably best if this behavior for define were used, otherwise

(define (foo x y)
 .
 .
 .
 (bar x)
 .
 .
 .
)

(define (bar x)
 .
 .
 .
)

will break.

But what do I know; I'm just a lurker. :^)

-- 
----------------------------------------------------------------------
Jeff Read <bitwize@geocities.com>
Unix Code Artist, Anime Fan, Really Cool Guy

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