This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Redefining functions interactively
- From: Per Bothner <per at bothner dot com>
- To: Chris Dean <Chris dot Dean at sokitomi dot com>
- Cc: Kawa List <kawa at sources dot redhat dot com>
- Date: Tue, 15 Apr 2003 09:09:23 -0700
- Subject: Re: Redefining functions interactively
- References: <19360.1050392248@mercedsystems.com>
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/