If you are adventurous, you might experiment with:
MAXIMA> (defmfun mreturn (&optional (x '$done))
(if (and (not mprogp) (not mdop))
(merror "`return' not in `block'"))
(throw 'mprog (ncons x)))
MRETURN
MAXIMA> (to-maxima)
Are these OK?
(%i20) (i:1, do ( i:i+1, if i=21 then return()), 2*i);
(%o20) 42
(%i21) return(42);
`return' not in `block'
(%i22) block([],return());
(%o22) done
(%i23) block([],return(%pi));
(%o23) %pi
The Lisp error is a bug:
(%i24) block([],return(%pi,7));
Maxima encountered a Lisp error:
BW
-----maxima-bounces at math.utexas.edu wrote: -----
>To: Maxima at math.utexas.edu
>From: "van Nek"
>Sent by: maxima-bounces at math.utexas.edu
>Date: 11/10/2007 09:23AM
>Subject: dummy argument to return
>
>Sometimes it nerves me to introduce a dummy argument to return from a
>loop.
>
>e.g.
>
>(%i1) (i:1, do ( i:i+1, if i=21 then return('dummy_argument) ), 2*i);
>(%o1) 42
>
>I do not use the return value here. I'd rather would like to write
>
>(i:1, do ( i:i+1, if i=21 then return() ), 2*i);
>
>I would like to see that return() is allowed. In that case do should
>return done as well or false
>according to an empty argument.
>
>Comments?
>
>Where is this mechanism defined? Tracing didn't help me very much. I guess
>there happens
>a caught throw.
>
>Volker van Nek
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima