diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2023-04-26 22:32:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-26 22:32:10 +0200 |
commit | 220b45048983998675df761d4f33cd31128f10d5 (patch) | |
tree | ddd2f63e18137db689f88ee814d6d2cf209ac01d /doc | |
parent | 8f79a124c96947283deecb137b7849557ae47f2f (diff) | |
download | Nim-220b45048983998675df761d4f33cd31128f10d5.tar.gz |
fixes #21245; warn about destructors that can raise (#21726)
* fixes #21245; warn about destructors that can raise * doc update * progress * typo
Diffstat (limited to 'doc')
-rw-r--r-- | doc/destructors.md | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/doc/destructors.md b/doc/destructors.md index a96ac35ef..a37eade33 100644 --- a/doc/destructors.md +++ b/doc/destructors.md @@ -13,12 +13,12 @@ Nim Destructors and Move Semantics About this document =================== -This document describes the upcoming Nim runtime which does +This document describes the ARC/ORC Nim runtime which does not use classical GC algorithms anymore but is based on destructors and -move semantics. The new runtime's advantages are that Nim programs become +move semantics. The advantages are that Nim programs become oblivious to the involved heap sizes and programs are easier to write to make effective use of multi-core machines. As a nice bonus, files and sockets and -the like will not require manual `close` calls anymore. +the like can be written not to require manual `close` calls anymore. This document aims to be a precise specification about how move semantics and destructors work in Nim. @@ -132,6 +132,14 @@ The general pattern in `=destroy` looks like: freeResource(x.field) ``` +A `=destroy` is implicitly annotated with `.raises: []`; a destructor +should not raise exceptions. For backwards compatibility the compiler +produces a warning for a `=destroy` that does raise. + +A `=destroy` can explicitly list the exceptions it can raise, if any, +but this of little utility as a raising destructor is implementation defined +behavior. Later versions of the language specification might cover this case precisely. + `=sink` hook ------------ |