-
Notifications
You must be signed in to change notification settings - Fork 133
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
Deprecate Optional #672
Deprecate Optional #672
Conversation
/cc @davidmorgan |
f5c172d
to
2e748ce
Compare
From offline discussion with @yjbanov, we may want to delay landing this until packages like What I may do is update this to simply update the docs to suggest people avoid adding new dependencies on it, then add the attribute once the major downstream packages have been migrated off. |
FWIW |
Oh - fantastic news! |
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.
2e748ce
to
04b921d
Compare
I've rebased to tip of tree. Once NNBD support is enabled across the board internally, I'll:
|
Null safe types are not a replacement for an Optional has a reason to exist. I just randomly stumbled across this PR, don't mind me, but you might want to check for that edge-case or decide to keep Optionals :) |
@modulovalue Can you explain a bit further? |
Map<String, Optional<User>> cache; // user by id
// there 3 cases:
cache['some_id'] == null; // -> does not contains in cache
cache['some_id]'.isPresent == true; // -> cache contains a User
cache['some_id'].isAbsent == true; // -> User not exists Sent from my Redmi 7A using FastHub |
@hoc081098 you can store a null value in maps today. Map<String, User?> cache;
cache['some_id'] == null; // -> unknown whether there is a mapping for 'some_id'
cache.containsKey('some_id') == false; // -> not contained in cache
cache.containsKey('some_id') == true; // -> cache contains a mapping for key 'some_id' In general, it is unsafe to assume that |
@cbracken let i: Int????? = nil // the variable i has the quiver-equivalent type Optional<Optional<Optional<...int>>> But that above is not expressible in dart without a wrapper int???? i = null; // compile time error To simulate the way that nulls work in swift, users would have to declare an Optional wrapper themselves. In other words, the Optional type allows users to define a nullable nullable value. An example where that could be useful can be seen here https://github.com/dart-lang/sdk/blob/8432b379e7fd2fae1e872ca20f9275366d49ffe0/pkg/vm_service/lib/src/dart_io_extensions.dart#L184-L185 |
I think nested optional type is a good point to keep |
@cbracken You can ignore my comments, I was wrong. I assumed Optional behaved more like a Maybe/Option Monad but it doesn't at all. |
Based on comments in b/258898406 internally, I'm going to rebase and land this. |
With the introduction of non-null by default in Dart SDK 2.12, existing users should migrate to non-nullable types. This type will be removed in Quiver 4.0.0.
04b921d
to
95868c5
Compare
With the introduction of non-null by default in Dart SDK 2.12, existing
users should migrate to non-nullable types. This type will be removed in
Quiver 4.0.0.
See: #666