-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dart:ffi canonical representation of C null pointer in Dart #35756
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
Comments
My recommendation: Don't use Do introduce a constant, say Maybe accept Counter-argument: If you ever want to have functions that don't accept null pointers, and we have non-nullable types, and the null-pointer is Naming Nitpick: Do not use |
Great suggestion! Any suggestion for what we should do with our struct sugar syntax abstraction? @ffi.struct
class Coordinate extends ffi.Pointer<ffi.Void> {
@ffi.Double()
double x;
@ffi.Double()
double y;
@ffi.Pointer()
Coordinate next;
} Should getters which point to other structs return Coordinate c;
c.next?.someMethod(); I guess the design question is: should interaction with structs feel more like Dart code or more like C? |
For the If it actually extends |
After deciding on how to represent null we could also consider the following.
note: currently |
This needs to be done together with #37229 assigning to @sjindel-google. |
There is no |
Should the canonical representation of a C null pointer be
Pointer(address=0)
ornull
?Our current approach is
null
. This is very convenient when calling functions:However, this also means that our
Pointer.fromAddress(0)
factory should returnnull
.Which would mean
Pointer.fromAddress(0).getAddress()
does not return0
but throws an exception.On the other hand, if
Pointer(address=0)
would be the canonical representation then the above snippet would be the following more verbose code instead:Another aspect is that the Dart
null
object does not carry a runtime type.A pointer with address 0 does carry a runtime type argument:
Would this runtime type argument for address 0 be useful in some scenario?
The text was updated successfully, but these errors were encountered: