Here is a unwind_protect function:
(defmspec $unwind_protect (e)
(setq e (margs e))
(unwind-protect (meval (first e)) (mapcar #'meval (rest e))))
And a function that determines the sign of an expression in
its own local context:
(%i2) my_sign(e, [f]) := block([prederror : false, my_context],
unwind_protect((
newcontext (my_context),
for fi in f do assume(fi),
sign(e)),
killcontext(my_context)))$
(%i3) my_sign(x, x > y, y > 1);
(%o3) pos
(%i4) my_sign(%i);
`sign' called on an imaginary argument:
After the error, 'my_context' still gets killed
(%i5) contexts;
(%o5) [initial,global]
I proposed the function unwind_protect sometime ago. Some thought
that 'unwind_protect' was an overly geeky function name, even by
Maxima standards :) I didn't think of a better name.
BW
-----maxima-bounces at math.utexas.edu wrote: -----
>To: Barton Willis <willisb at unk.edu>
>From: "van Nek" <van.nek at arcor.de>
>Sent by: maxima-bounces at math.utexas.edu
>Date: 11/10/2007 01:26PM
>cc: Maxima at math.utexas.edu
>Subject: Re: [Maxima] dummy argument to return
>
>Am 10 Nov 2007 um 12:22 hat Barton Willis geschrieben:
>
>> OK, another idea: make return act like unwind-protect. Then it would
>> (1) evaluate and return the first and (2) evaluate the remaining even
>> if evaluating the first signals an error.
>
>Barton,
>do you have an example in mind which shows the benefit of this behaviour?
>
>Volker
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima