-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Rename None to Union() and Nothing to Void? #8423
Comments
In the spirit of "None -> Union()", one could also "Nothing -> ()", i.e. the empty tuple. Functions return multiple values as tuples, so a function returning nothing returns |
I like that idea, but believe it might require a change in semantics rather than a change in names. |
And what about EDIT: for reference, https://github.com/johnmyleswhite/NullableTypes.jl/pull/3 |
Would we really need a separate type for NullableArrays? Or would they just On Sat, Sep 20, 2014 at 5:38 AM, Milan Bouchet-Valat <
|
Arrays of Nullables would not have good performance characteristics or memory efficiency. |
I'm fine with renaming None to Union() but I think renaming Nothing to Void would be a mistake. The empty tuple is a completely valid and useful value – using it to indicate that there's nothing interesting to return is not a good idea. |
Yes we cannot use I think making I would much prefer simply renaming |
@nalimilan: My plan is to remove In Julia, we started with an approach in which One could improve support for union types in Julia substantially using techniques like polymorphic inline caching, but Jeff and others felt that this was not the best way to move forward. I've also come to feel that Julia doesn't use From my perspective, Julia's union types tend to be used only for writing out a catch-all case that expresses a generic statement about all types. Specialized cases are handled via multiple dispatch, rather than pattern matching with exhaustive case analysis. As such, I don't think Julia's union type will ever come to be used in the same way that functional languages use their sum types. This makes me think that the old |
@quinnj: The plan is to maintain a separate Pros:
Cons:
I think we'll end up revisiting this question a few times, but I think the current plan is the best one we have so far. |
@JeffBezanson and @StefanKarpinski: How about starting by making |
Yes that's probably what we'd do anyway as a deprecation process. If we had a general way to do the array-of-structs-to-struct-of-arrays transformation, then NullableArray could become redundant. But that is a significant challenge. |
On Sat, Sep 20, 2014 at 1:38 PM, John Myles White [email protected]
-erik Erik Schnetter [email protected] |
Can't we support both by just writing DataFrames et al. to work with any representation that takes indices and produces Nullables? That would include both |
We can certainly support both in some cases, but it seems pointless to recreate the work we've done to support things like matrix multiplication for |
@johnmyleswhite Fine, but then how would you set an element of a |
|
We can have some value of type |
It is worth noting that we didn't opt into using There are some potential gains from having |
@johnmyleswhite Two big differences from the R behavior illustrated in your commit are that 1) |
@nalimilan: That solves the specific issue in that gist, but doesn't solve the broader lesson: it's dangerous to teach people to think about values that have ill-defined positions in the type system. Even though |
I think that having |
Abstractly, I agree that having I'm happy to allow But I'm worried about people writing functions like:
I'm especially worried that the brevity of |
It is also confusingly different from what NULL means in C and java and all |
This problem could also be avoided by allowing type annotations on functions -- similar to local variables -- and then automatically converting the returned value to this type. |
That's #1090. |
If people want shorter ways to create appropriate |
I'm also ok with that. |
Is the name I believe Swift uses a question mark after the type to indicate types that are nullable, e.g. |
A bunch of languages use |
I thought the discussion above was about introducing |
Yes, but I don't actually think we need to make any changes. If we do make changes to provide shorthand for typed nulls, I think |
Or |
OTOH there's To me the strongest argument in favor of |
I think we can set up |
In the discussion of #8152, there was some concern about the potential existence of three "NULL"-like types in Julia:
One suggestion was to rename types to clarify their purpose. @JeffBezanson suggested renaming
None
toUnion()
andNothing
toVoid
to reflect their respective roles as the empty union of zero types and the result of functions that "do not return a value".I personally think this would be a great change.
The text was updated successfully, but these errors were encountered: