[Bese-devel] the limitations of the code within actions
Matthew Danish
mdanish at andrew.cmu.edu
Thu Feb 2 16:42:48 UTC 2006
On Thu, Feb 02, 2006 at 09:57:18AM +0100, henrik hjelte wrote:
> On ons, 2006-02-01 at 18:30 -0500, Matthew Danish wrote:
> > I tried to use a HANDLER-CASE form within a defaction and it seems that
> > Arnesi's library can't handle that (in this case it expanded to a
> > MULTIPLE-VALUE-PROG1 which caused it to choke). Is this a limitation I
> > should expect, or is it a bug?
> >
> Maybe Marco has a better answer, anyway here is mine.
> This is an expected limitation. One work-around could maybe be to split
> up the defaction form so it calls a helper method /function that
> contains the handler case.
> The interpreter only walks the forms in the defaction form, so if you
> put the code in a method or function instead you are back in plain Lisp.
>
> /Henrik Hjelte
>
> (defaction my-action ((c my-component))
> (handler-case
> (do-stuff)
> (error (e)
> ...)))
>
> becomes:
>
> (defaction my-action ((c my-component))
> (when (my-action-method c)
> (answer 'ok)))
>
> (defmethod my-action
> (handler-case
> (do-stuff)
> ;; Note you can't call 'components or answer here
> (error (e)
> ...)))
>
Well this is basically what I did, but it did bring up another problem:
I used MULTIPLE-VALUE-CALL to invoke an outside normal function which
handled the errors and returned values indicating what happened. What
it returned, however, was not what I expected:
(multiple-value-call
(lambda (cc result msg)
What I found was that the first value returned was some kind of Arnesi
data structure named CLOSURE, rather than my result. I inserted the
extra parameter cc into the function and now it works fine, but this
makes me wonder if there is something better I can do here.
--
;; Matthew Danish -- user: mrd domain: cmu.edu
;; OpenPGP public key: C24B6010 on keyring.debian.org
More information about the bese-devel
mailing list