-
Notifications
You must be signed in to change notification settings - Fork 21
Behavior of map() and broadcast() #144
Comments
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Another way to put the issue is that the semantics for functions that act directly on the Note also that comprehensions always give julia> X = NullableArray(collect(1:3))
3-element NullableArrays.NullableArray{Int64,1}:
1
2
3
julia> [ isnull(x) for x in X ]
3-element Array{Bool,1}:
false
false
false |
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
I don't really like the idea of specializing on specific functions, as it will make it very hard to understand the general behavior of |
To add to David's comment, the main concern I have with this proposal is that it would make it too easy for the semantics of Consider the following example: f(x::Int) = 1
f(x::Nullable{Int}) = 2
map(f, 1:3)
map(f, NullableArray(1:3)) What do these two calls to This concern is closely linked to the whitelist vs blacklist distinction I've been discussing with David for a while now: Blacklist approach: We automatically lift all functions for you in contexts like Whitelist approach: We never lift any functions automatically. You always have to define their behavior on nullable objects manually. We imagine you'll usually obey our default semantics, but we want you to always opt-in. Which of these approaches is best is admittedly unclear. But I'm currently inclined to think that the blacklist approach will involve less work in the long run and will prevent paradoxes in which the action of functions on nullables and non-nullables is different from unclear reasons. |
OK. I was rather trying to ensure consistency with map(f, [Nullable(1), Nullable(2), Nullable(3)]) == map(f, NullableArray(1:3)) No divergence would be allowed between Whatever the choice, I don't like the idea of a list, be it black or white: it makes things inconsistent and harder to understand/predict. Let's lift everything or nothing by default. |
To clarify, lifting nothing by default is what I mean when I talk about using a whitelist strategy. In that case, the whitelist is literally Julia's method table since the only methods that apply to nullable objects are then methods that explicitly are defined over nullables using normal method definitions. I think it's reasonable to lift everything with I may regret this view later, but I would prefer that we ignore the |
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Shorter written that way for now. Filed as JuliaStats/NullableArrays.jl#144.
Currently,
map
/broadcast
onNullableArray
returns aNullableArray
. This can be annoying when you don't want aNullable
result, e.g.:I think it would make sense to return a
NullableArray
only when the function returnsNullable
. This is similar to operations onBitArray
: JuliaLang/julia#18198The text was updated successfully, but these errors were encountered: