Water 5-Flow Control and Boolean-Sequential FlowContract| Parameter key | Default value | Type | | value | null | | from | null | | Water Contract<class return
value=null
from =null
/> | |
See also: method, for_each, break
When a call to return is executed, the execution of the current sequence of instructions is
stopped and the specified value is returned; if value is not specified,
it defaults to null .
In many programming languages, return is a required keyword used to indicate the return
value of a method. In Water methods, the last result value of a sequence of instructions is
the return value; the return value is said to be implicit .
Example: Implicit return value (last value)
<method foo> 543 555 </>
<foo/>
 | 555 |
a wob
| Parameter key | Default value | Type |
| value | null |
An explicit
call to return is usually not needed in Water. A call to return is only needed for
those occasions when it is necessary to halt the current
execution sequence somewhere before the end, and return a value immediately,
skipping the remainging instructions.
a wobvalue=null
Example: Explicit null return value (not last)
<method foo> <return /> 555 </>
<foo/>
 | null |
a wobvalue=wob
Example: Explicit Water object return value (not last)
<method foo> <return 543 /> 555 </>
<foo/>
 | 543 |
a wob
| Parameter key | Default value | Type |
| from | null |
The from argument specifies how far up the call stack to halt the execution
of instructions.
a wobfrom=null
If
from is not specified, or if it is
null,
return returns from
the current enclosing expression.
<method foo> <return 543 /> 555 </>
<foo />
 | 543 |
a wobfrom="method name"
If
from is the name of a method, then it returns from the
innermost method call of that name.
<method foo> <return 543 from="foo"/> 555 </>
<foo/>
 | 543 |
<method foo> <return 541 "baz" /> 559 </>
<method bar> <foo/> 669 </>
<method baz> <foo/> 779 </>
<baz/>
 | 541 |
a wobfrom="all"
If there is no method by that name on the stack, then all methods
on the stack are returned from. A convenient way to return from all methods is to use a value for
from
of
"all". In that case, the value returned
will be the
return object itself, which will have fields of
value and
from.
<method foo> <return 540 "all" /> 559 </>
<method bar> <foo/> 669 </>
<method baz> <bar/> 779 </>
<baz/>.value
 | 540 |
a wobfrom="for_each"
If
return is used to return from a
for_each loop, the value
specified will be returned instead of the loop's current
for_each_result.
10.<for_each >
<if> value.<more 7 /> <return <thing color="red" /> from="for_each" /> </if>
value
</for_each>
 | <thing color="red"/>
|
© Copyright 2007 Clear Methods, Inc.