-
-
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
Optionals #2762
Optionals #2762
Conversation
/cc @dom96 @Araq @bluenote10 |
Ready to be merged as far as I'm concerned. One small issue that I have is the use of So yeah. Once @Araq is happy with it we can merge it. |
I didn't notice the |
Yeah. Sounds good. |
I am also wondering whether we are now encouraging the use of |
@dom96 good point re. typedesc. Maybe |
Yes, this is looking good. The only thing I would add is the implementation of
From a foreign module, any attempt like this
currently leads to Just out of curiosity: What is wrong with (*) I came upon this issue before and noticed that a simple |
Please create a PR for this anyway. I wouldn't want this to get lost in the noise of this discussion. I agree with @bluenote10, let's add In regards to |
It is inconsistent on call-site anyways, since nobody will write |
hrm. Good point. |
Ok, done. |
Why did you close this? |
Looks like I accidentally deleted the branch in my repo. Sorry about that! |
So favor this PR over #2515? |
Yep. |
I liked the |
Please remove me as the author. Nothing that remains in this pull request was my idea. By the way, I would hate using such a module. Absence of "get-or-default" is preposterous. |
@BlaXpirit We can add that later. |
Done on request, see #2762 (comment)
@BlaXpirit |
I disagree with some removals, but that's OK. Probably time to merge. |
|
||
|
||
proc unsafeGet*[T](self: Option[T]): T = | ||
## Returns the value of a `just`. Behavior is undefined for `none`. |
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.
What's a "just"? ;-)
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.
Fixed.
Ok, shedding time.. Get-or-default kind of is a must-have when juggling with maybes. |
That's not really controversial. The controversial part is what exactly the syntax for them should be. |
Based heavily on #2515, but lots of stuff is ripped out and modified.
Contents:
some
,none
,isSome
,isNone
,get
,unsafeGet
,==
Option[T]
typeunittest
moduleThis PR is purposely kept very simple in order to avoid bikeshedding and to get it merged. The reasoning is that new things can always be added in future PRs, removing functionality is much more difficult.