-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
Updated specification for Std.is / safe cast #7115
Milestone
Comments
The canonical implementation of |
The new one will be |
I don't want another discussion topic, thanks |
Closed
Closing in favor of #7532. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given there was a disagreement over the specification of Std.is / safe cast, I'm using my dictatorship power to move forward for Haxe 4.0:
Std.is(null,T)
should be false :null
value has no runtime type information attached so while it's a valid value for a variable of type T it's not an object instance of T either, which is what Std.is is checking.cast(null,T)
should be null (not throw), because in that case we convert the valuenull
to type T and it's valid value for this type. Also both(null : T)
and(cast null : T)
works. That's the way type casting works in C#, Java, and many other languages.Requirements:
Additional checks:
catch( e : Dynamic )
cast(null,Int|Float|Bool)
: on static platforms, return the default value (same as unsafe cast). on dynamic platorms, returns null.Std.is(null,Int|Float|Bool|Dynamic)
: should befalse
on all platforms as wellThe text was updated successfully, but these errors were encountered: