dummy argument to return



Unless somebody has a better name or implementation, I'll commit
unwind_protect to /share/contrib. The name might give
users the impression that they need to learn CL to work with Maxima.
And maybe that's a good thing :)

My idea of blending return with an unwind-protect was a brainstorm.

BW

-----"van Nek"  wrote: -----

>To: Barton Willis
>From: "van Nek"
>Date: 11/11/2007 05:46AM
>cc: Maxima at math.utexas.edu
>Subject: Re: [Maxima] dummy argument to return
>
>
>
>
>
>
>
>Another example of usage of $unwind_protect could be to close a stream if
>an error occurs
>while working with it.
>
>
>
>You should commit this useful function. I would not consider another name
>cause at first
>sight it does nothing different than unwind-protect but only on Maxima
>level. So why
>creating another name for the same thing?
>
>
>
>But I think this is another thread. Originally it starts with my attempt
>to simplify the return
>function. I wouldn't like to mix this. According to Robert I would like to
>see a simple
>definition for return:
>
>
>
>return() ==> false
>return(expr) ==> expr
>return(1,2,3) ==> Maxima error
>
>
>
>expr can be an assignment, a list or an unwind_protect or whatever.
>
>
>
>Volker van Nek
>
>
>
>
>
>
>Am 10 Nov 2007 um 19:45 hat Barton Willis geschrieben:
>
>
>
>> 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
>> >From: "van Nek"
>> >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
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima