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

std/options: $some(3) is now "some(3)", etc. #17147

Merged
merged 3 commits into from
Feb 24, 2021

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Feb 22, 2021

refs #17036 (comment)

  • $some(3) is now "some(3)", not "Some(3)", $none(int) is now "none(int)" instead of "None[int]"
  • use -dnimLagacyOptionsDollar for previous behavior.

rationale:

  • Some and None don't exist as symbols
  • Some(3) would imply you'd have a type Some, but then Some(3) syntax would be illegal
  • it also makes more sense in the syntax of fusion/matching, see below

note

I've disabled optionsutils which had a failing test due to this change:

tests/test2.nim(57, 17): Check failed: echoed == "Some(10)"
      echoed was some(10)
tests/test2.nim(61, 17): Check failed: echoed == "None[int]"
      echoed was none(int)

Future work

{.experimental: "caseStmtMacros".}
import fusion/matching
case some(42)
of Some(@a): assert a == 42
of None(): assert false
assertMatch(some(some(none(int))), Some(Some(None())))

=> this:

{.experimental: "caseStmtMacros".}
import fusion/matching
case some(42)
of some(@a): assert a == 42
of none(): assert false # or maybe `none` instead of `none()`
assertMatch(some(some(none(int))), some(some(none())))

(EDIT: followup discussing this point here: timotheecour#612)

@timotheecour timotheecour changed the title std/options: $some(3) is now "some(3)", etc. std/options: $some(3) is now "some(3)", etc. Feb 22, 2021
@konsumlamm
Copy link
Contributor

konsumlamm commented Feb 22, 2021

Regarding fusion/matching, I think it would be more consistent to keep using Some and None, since that fits in with using uppercase kinds for variant objects.

EDIT(timotheecour): let's followup discussing fusion/matching renaming Some, None to some, none in here: timotheecour#612

@timotheecour timotheecour added the TODO: followup needed remove tag once fixed or tracked elsewhere label Feb 22, 2021
@dom96 dom96 merged commit 578d1ee into nim-lang:devel Feb 24, 2021
@timotheecour timotheecour deleted the pr_options_Some_some_dollar branch February 24, 2021 22:25
timotheecour added a commit to timotheecour/nim-optionsutils that referenced this pull request Feb 25, 2021
PMunch pushed a commit to PMunch/nim-optionsutils that referenced this pull request Mar 2, 2021
ringabout pushed a commit to ringabout/Nim that referenced this pull request Mar 22, 2021
* std/options: $some(3) is now "some(3)", not "Some(3)", `$none(int)` is now `"none(int)"` instead of `"None[int]"`

* fix tests

* disable optionsutils
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
* std/options: $some(3) is now "some(3)", not "Some(3)", `$none(int)` is now `"none(int)"` instead of `"None[int]"`

* fix tests

* disable optionsutils
@metagn metagn removed the TODO: followup needed remove tag once fixed or tracked elsewhere label Jan 4, 2024
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.

None yet

5 participants