Upgrade Code Examples
Embedded Loops in Argument List
If you used the result of a leave-with inside an argument list like the following, you will need to re-work the code to be a simple argument list as seen below.
The following code will produce the error:
**** Error: Java exception java.lang.RuntimeException: Method compilation would result malformed stack.
java_error(exception_type=:|java.lang.RuntimeException|, message="Method compilation would result malformed stack.")
_method system.malformed_stack_example()
_local els << {1,2,3,4,5}
_local pl << property_list.new_with(
:test,12345,
:four,_for a _over els.fast_elements()
_loop
_if a = 4
_then
_leave _with a
_endif
_finally
_leave _with :a4
_endloop)
print(pl)
_endmethod
$
Example of code that can be compiled in Smallworld 5
_method system.malformed_stack_example()
_local els << {1,2,3,4,5}
_local val << _for a _over els.fast_elements()
_loop
_if a = 4
_then
_leave _with a
_endif
_finally
_leave _with :a4
_endloop
_local pl << property_list.new_with(
:test,12345,
:four,val)
print(pl)
_endmethod
$
page revision: 1, last edited: 16 Sep 2016 18:49