Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.24 KB

must.rst

File metadata and controls

41 lines (29 loc) · 1.24 KB

Must

A :mini:`must`-declaration can be used to ensure that particular code is guaranteed to run before a block is finished, even if an error occurs or :mini:`ret`, :mini:`exit`, :mini:`while`, :mini:`until` or :mini:`next` is used to exit the block early.

.. parser-rule-diagram:: 'must' expression

Note

Since :mini:`susp`-expressions can resume the current block, they do not run :mini:`must` code. In general, do not use :mini:`must`-declarations with :mini:`susp`-expressions unless it known that the generating function will always be completed.

Note

In order to guarantee a valid state when each :mini:`must`-expression is executed, each :mini:`must`-declaration implicitly creates a new block around the code that follows it. Given code like:

decls
code
must X
decls
code

the compiler treats it internally as similar to:

decls
code
do
   decls
   code
   X
on Error do
   X
   Error:raise
end

This means that some forward declarations that work without :mini:`must` may not work when :mini:`must` is present. This limitation might be removed in the future.