return. Returning from a method   [3.4.5]


^return[]
^return[result value]

If called force finishes a Parser method execution, in which the
^return[] call code is written. The result of the method will be what was output before the ^return[] call or the current value of $result variable. The call ^return[result value] is equivalent to $result[result value] ^return[].

Пример
@main[]
$exit{ 
-return- ^return[] }
^check[
good]{ $exit }
^check[
normal]{ $exit }
^check[
bad]{ $exit }
-end-

@check[value;exit]
Value: $value ^if($value eq 'bad'){ $exit } -passed-

Outputs:

Value: good   -passed-
Value: normal -passed-
Value: bad    -return- 

Note:
^return[] call code is written in the @main[] method, so the return is made from it. To do this, the execution of the @check[] method is also terminated, so there is no -passed- for the value bad in the output.


Copyright © 1997–2017 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 20.04.2017