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

Add comparison of null/nil safety and syntax #36

Merged
merged 2 commits into from
Apr 20, 2020

Conversation

roryokane
Copy link
Contributor

I researched these features because I was wondering if either language had a solution like Rust’s Option. Neither language does.

I decided the comparison result was “?” because D is better by default because more of its built-in types are non-nullable, but Nim can be made safer than D if you put in the work of redefining everything using the experimental not nil type annotation.

@roryokane
Copy link
Contributor Author

roryokane commented Mar 25, 2020

By the way, regarding this part of my description of Nim’s null handling:

The notnil feature was made experimental in 2018, but in 2020 its brief documentation is still in the wrong section of the manual

I plan to make a PR for Nim to move the not nil documentation to the correct section of the manual. I will update this PR if and when that Nim PR is merged.

In that potential future update to this PR, I will update the link to not nil’s documentation. But I won’t remove all mentions of the docs being in the wrong section of the manual – it having been that way for years is still good evidence that not much attention is paid to this feature.

README.md Outdated Show resolved Hide resolved
@timotheecour
Copy link
Owner

timotheecour commented Mar 30, 2020

thanks for the PR! just click resolve on each comment when you've addressed it (easier to track each independently)

@timotheecour
Copy link
Owner

ping @roryokane

also see this:
https://irclogs.nim-lang.org/06-04-2020.html#13:52:31

Araq | isNil could be deprecated, it's pointless

which echos what I was thinking as well, now that seq/string can't be nil

@timotheecour timotheecour mentioned this pull request Apr 7, 2020
1 task
I researched these features because I was wondering if either language had a solution like Rust’s `Option`. Neither language does.

I decided the comparison result was “?” because D is better by default because more of its built-in types are non-nullable, but Nim can be made safer than D if you put in the work of redefining everything using the experimental `not nil` type annotation.
roryokane added a commit to roryokane/D_vs_nim that referenced this pull request Apr 20, 2020
@timotheecour
Copy link
Owner

Only ptr and ref types (and cstrings) can be nil

actually, also pointer, but... can be fixed, later.

super thanks! 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.

2 participants