This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Redefining functions interactively


Chris Dean wrote:
I would like to redefine functions in a specific module when running interactively. Is this a supported feature?

However, Kawa optimizes functions using the syntax (define (f args) ...) assuming that f is constant.

Instead, you have to define f as a variable:
  (define f (lambda (args) ...))

R5RS defines these to be equivalent, but then R5RS doesn't
define separate compilation.  (Kawa's approach does appear to
be compatible with what Common Lisp specifies.)

For example, assume I have a module Foo that has two functions: "inner"
and "outer".  I would like to run kawa interactively, require Foo, and
then redefine the function "inner" and have "outer" use the new "inner".

    (module-name <Foo>)
    (module-static #t)

(define (inner) 'inner)

Replace this line by: (define inner (lambda () 'inner))

The late redefinition works as written (as least currently!),
but stylistically I would recommend:
  (set! inner (lambda () 'inner-2))
--
	--Per Bothner
per at bothner dot com   http://per.bothner.com/



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