[comp.lang.lisp] A Franz Lisp question.

misha@shum.huji.ac.il (02/26/90)

As a novice to Franz Lisp, I have the following question:

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:

(Scheme):

(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.]

Am I right? And if I am not, how is it done then?


Thanks,
   Misha.

jeff@aiai.ed.ac.uk (Jeff Dalton) (02/27/90)

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