-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: move not nil
to the experimental page
#14027
Conversation
When I heard that this feature existed, and found the 2018 changelog entry that said `not nil` was made experimental (https://github.com/nim-lang/Nim/blob/devel/changelogs/changelog_0_19_0.md#changes-affecting-backwards-compatibility), I looked for `not nil` documentation in https://nim-lang.org/docs/manual_experimental.html. When I didn’t find it there, I initially assumed the feature had no documentation. This change moves the documentation to where readers will expect it. As well as moving the text to another file, I added instructions for enabling the experimental feature and tweaked some wording.
Note to self: this change will affect the URL added to the D/Nim comparison table in timotheecour/D_vs_nim#36. So update that PR or make a new PR in that project after this is merged. |
@@ -340,6 +340,36 @@ This operator will be matched against assignments to missing fields. | |||
a.b = c # becomes `.=`(a, b, c) | |||
|
|||
|
|||
Not nil annotation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this changed markup in a ReStructured Text editor and it looked mostly good, but I couldn’t confirm that the .. code-block:: nim will render correctly since that’s a custom block type defined by this project.
nim rst2html foo.rst
or for whole docs you can ./koch docs
|
||
# and also this: | ||
var x: PObject | ||
p(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except it doesn't.... so I'd reword for honesty as:
# and also this:
=>
# but not yet this:
when true:
{.experimental: "notnil"}
type
TObj = object
PObject = ref TObj not nil
TProc = (proc (x, y: int)) not nil
proc p(x: PObject) =
echo "not nil"
echo x == nil
# compiler catches this:
# p(nil)
# and also this:
var x: PObject
p(x)
prints:
not nil
true
maybe you could pull up some other compelling example from #13808 /cc @zah
{.experimental: "notnil"} | ||
|
||
type | ||
PObject = ref TObj not nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add TObj = object
(basically make sure it compiles )
Can also move for loop macros and code reordering. |
This PR at least improves the situation, merging. |
When I heard that this feature existed, and found the 2018 changelog entry that said
not nil
was made experimental, I looked fornot nil
documentation in https://nim-lang.org/docs/manual_experimental.html. When I didn’t find it there, I initially assumed the feature had no documentation. This change moves the documentation to where readers will expect it.As well as moving the text to another file, I added instructions for enabling the experimental feature and tweaked some wording.
I tested this changed markup in a ReStructured Text editor and it looked mostly good, but I couldn’t confirm that the
.. code-block:: nim
will render correctly since that’s a custom block type defined by this project.