Closed jonathanabennett closed 5 years ago
No. The manual states that the defer
statement is rewritten to this by the compiler. This is either a regression in the compiler or an intended change, so we might need to put all examples in a proc.
It's actually likely that defer
was never supported at the top-level.
This was kind of a simple-minded approach to solving the problem, but it should do for the examples.
We can close this issue as I've tested all of the examples.
When attempting to compile any of the examples under nim 0.20, you receive the following error: Error: defer statement not supported at top level
Presumably, this is caused by the defer: nb.shutdown() present in all examples. According to the language manual, these should probably be try, finally statements when located at the top level.
If that is the preferred method, I will submit a pull request rewriting existing examples in that idiom, but it seems like that would be a rather large try block for any non-trivial program.