-
-
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
initialize Arrays with great dignity #24652
Conversation
I'd be happy to have |
If |
@Sacha0, I love your attitude and sense of humor! |
To clarify, the analysis in #24595 does not support deprecating all convenience constructors. Rather, that analysis suggests that certain existing convenience constructors make a poor foundation on which to build more general array constructors, and that the set of existing |
Much thanks for the kind words |
What is planned for |
|
A miscommunication: I don't want to discuss |
FWIW I prefer |
On the subject of whether to introduce an |
Do you mean "type" or "instance of a type"? Latest developments seem to favour dispatch on instances (e.g. |
That's true (though quoted slightly incorrect: it's For consistency (capitalization of types), I would also favour a singleton type with a single instance struct Uninitialized end
const uninitialized = Uninitialized()
function Array{T,N}(::Uninitialized, ...) which can then be called as |
To clarify, we need |
Rebased and updated with the implementation |
The latest iteration appears to be in shape. Absent objections or requests for time, I plan to merge these changes tomorrow evening (Tuesday evening PT) or later. Best! |
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.
Looks good, but tests and docs would be nice :)
@@ -123,7 +123,7 @@ export | |||
SimpleVector, AbstractArray, DenseArray, NamedTuple, | |||
# special objects | |||
Function, CodeInfo, Method, MethodTable, TypeMapEntry, TypeMapLevel, | |||
Module, Symbol, Task, Array, WeakRef, VecElement, | |||
Module, Symbol, Task, Array, Uninitialized, uninitialized, WeakRef, VecElement, |
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.
Should Uninitialized
be exported? It does not seem necessary for the usage
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.
Uninitialized
must be exported, lest Julia not build :).
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.
Why is that?
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.
Uninitialized
/uninitialized
must be visible everywhere uninitialized arrays are or will be constructed; these exports make Uninitialized
/uninitialized
visible beyond Core
. The build failure absent these exports comes from the definitions using Uninitialized
/uninitialized
in sysimg.jl
. Does that clarify? :)
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.
Though wouldn't it be possible to export only uninitialized
from Base (not Core)? Should Uninitialized
be used outside of Base?
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.
Uninitialized
should see use outside Base, yes, in definitions of constructors for uninitialized arrays generally (see #24595). Additionally uninitialized
is merely an alias for Uninitialized()
, and hence uninitialized
cannot do its magic without Uninitialized
visible. Does that clarify? :)
Array{T,2}(m::Int, n::Int) where {T} = | ||
## primitive Array constructors | ||
struct Uninitialized end | ||
const uninitialized = Uninitialized() |
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.
This could perhaps use a docstring -- I think uninitialized
will be something people will look up in the manual when it goes live.
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.
Good call! I will add docstrings shortly :).
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.
Docstrings live. Thanks! :)
By nature of underlying every |
Makes sense. Also, sorry for beeing a pain, but do you mind adding the docstrings to |
Not at all a pain! To the contrary, I much appreciate your thorough and rapid reviews, and comments like these are super helpful! Revised accordingly, and thanks again! :) |
…initialized, dims...) etc.
Thanks all! :) |
This constructor overwrites what was added in #24652. As long as memory is uninitialized (rather than zeroed) by default, these constructors do the same thing. Removing this constructor fixes a method overwritten warning during the build.
This constructor overwrites what was added in #24652. As long as memory is uninitialized (rather than zeroed) by default, these constructors do the same thing. Removing this constructor fixes a method overwritten warning during the build.
This constructor overwrites what was added in #24652. As long as memory is uninitialized (rather than zeroed) by default, these constructors do the same thing. Removing this constructor fixes a method overwritten warning during the build.
This pull request replaces the existing primitive
Array
constructors with equivalents requiringuninitialized
as their first argument, e.g.Array{T,N}(d::VarArg{Int,N}) -> Array{T,N}(uninitialized, d::VarArg{Int,N})
, and reimplements the existing constructors in terms of those new equivalents.This pull request is the equivalent of #24400 with
uninitialized
in place ofjunk
, and is the first 1.0-necessary step for #24595.Question:
uninitialized
is presently a methodless function (as withjunk
in #24400), which makes sense only if we plan to simultaneously introduce a convenience constructoruninitialized(T, shape...)
. But if we do not introduce such a convenience constructor, then perhapsuninitialized
should instead be a type. IIRC, whether we should introduce such a convenience constructor hasn't been explicitly decided yet. Thoughts? Thanks and best!