Skip to content
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

Merged
merged 1 commit into from
Apr 21, 2020

Conversation

roryokane
Copy link
Contributor

When I heard that this feature existed, and found the 2018 changelog entry that said not nil was made experimental, 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.

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.

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.
@roryokane
Copy link
Contributor Author

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
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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 )

@metagn
Copy link
Collaborator

metagn commented Apr 20, 2020

Can also move for loop macros and code reordering.

@Araq
Copy link
Member

Araq commented Apr 21, 2020

This PR at least improves the situation, merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants