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

Re: A Franz Lisp question.



In article <660@shuldig.Huji.Ac.IL> misha@boojum.huji.ac.il writes:
>As you all might well know, Franz Lisp is a dynamic binding langauge, while
>Scheme is not. Therefore, the following code is unwriteable in Franz Lisp:
>
>(define (func param)
> (lambda (x) (param x)))
>
>[This function accepts a parameter which is also a function, and returns yet
>another function which 'apply's param on x.]

In Opus 38.92, you would write this:

(declare (special param))

(defun func (param)
  (fclosure '(param)
    #'(lambda (x) (funcall param x))))

"funcall" is used to call a functional object.  "fclosure" is
used to make a closure over dynamic (ie, special) variables.
Hence "param" must be declared special if you want your code
to compile correctly.

The problem with compilation occurs because Franz is not a totally
dynamic binding language.  It is for interpreted code, but in compiled
code variables have lexical scope (but only dynamic extent) by default.

-- Jeff