"return" exits from the innermost (dynamic) block surrounding it. This may be a 'block' or a 'do'. Note that a function body is not a block:

block( return(3)) => 3
do return(3) => 3

​​
​In your example​, 'return' returns from the block, not from the for/do:
​​

​for k thru 3 do block( print(k), if k=2 then return(23), print(k*10) )

prints 1,10,2,3,30 and returns 'done'.

                  -s​

​​​

On Sun, Apr 27, 2014 at 5:49 AM, Helmut Jarausch <jarausch@igpm.rwth-aachen.de> wrote:

The documentation says:
   Note however that a return within a do that occurs in a block
   will exit only the do and not the block.

The following do does not occur within a block, so why does


RetVal:for k in [1,2,3] do block(
    if k=2 then return(7))$

print(RetVal)$

print 'done' instead of 7 ?

Thanks for an explanation and a work around,
Helmut
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Maxima-discuss mailing list
Maxima-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maxima-discuss