-
-
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
WIP: redesign of tuples and tuple types #10380
Conversation
I can't find anything to complain about in that list. Quite the contrary, in fact. |
I bet we can find a better usage for I will also express my negative feelings for pushing the 0.4 release further into the future. We're past due already, and stalled releases gives a negative impression about our progress. (If this gets into 0.4, we'll also need to keep Ps: otherwise this seem like a really great change! |
+1 for every single suggestion... Does this also mean that a |
@ivarne What candidates do you have in mind for an alternative use of |
Hmm, @ivar's point about one cycle's worth of deprecation for |
@nalimilan See #10386. (@timholy I'm |
Sorry to both. |
I'm willing to use @Jutho yes tuples of bits types will be inlined. As for release timing, my current thinking is to get this change in, but punt most of the rest of what's currently in the 0.4 milestone. Any very disruptive changes that we know we need, we should do as soon as possible. Many of the other 0.4 issues are not that disruptive, e.g. if they can be deprecated easily. |
What about |
That's an interesting idea. Off-line I actually worked through ~3 possible designs for this, and I considered some things like that. One unusual feature of such a design is that the length of a tuple is not actually stored anywhere; you just have a cycle of objects for each possible length. Of course you could store the length anyway, but you can't get to it just by looking at the parameter(s) of a tuple type, which is a bit surprising. It also entails allocating more objects per tuple type, and there are a lot of tuple types. |
I was just thinking that allowing varargs parametric types was kind of a complication to the type system. Would you be able to declare your own varargs parametric types? Or would it be something that is special to |
Aren't types kind of varargs already (in that you can have incompletely specified types like |
I wasn't planning to add general varargs type parameters; this would be specific to tuples. Varargs parameters could mean two things: allowing a type to be instantiated with any number of parameters, or allowing We don't have this already, because the number of parameters is always limited. No type actually accepts any number of parameters (except tuples). |
Could |
Ok. |
I don't like the {} syntax, because it's at odds with mathematical notation, where curly braces denote sets, and most other programming languages, where curly braces denote unordered collections. (E.g., in python, where {} constructs a set or dict, and Lua and Matlab, where {} constructs an unordered map.) |
@joschu we already use curly brackets to denote tuples of types in a lot of places though, e.g. type MyType{A,B}
foo::A
bar::B
end
MyType(5.0, 2) # MyType{Float64,Int} So it doesn't seem too ambiguous |
It kind of makes sense:
|
Ah! I misread the original proposal as saying that all tuples would be constructed using that notation. |
246c078
to
a01f07e
Compare
Making good progress here. One minor thing I ran into: it's a bit odd that usually And a major thing: we have no way to destructure tuple types. We used to be able to use all tuple functions on tuple types, which was pretty convenient, but we've never had variadic DataTypes before so there's no infrastructure for that. This mostly affects The traditional approach would be a recursive representation, e.g. the type of |
Making the type parameter the tuple of types solves both of these issues, no? |
A good way to do that would be to have a I hesitate there because of the large number of silly tuple types we'd need to generate: |
I thought my last commit did not work. Funny thing is, it actually did work, but just took so long to start up that I gave up waiting... how amusing... :) |
👍 |
If anybody wants to kick the tires, this is now usable with sys0.ji. Don't try to build sys.ji; just interrupt it. |
Makes sense, thanks for the clarification. |
I believe the bug was due to the need to hash typename->primary specially, based on how other type functions treat it.
…0875) - add a linearly-searched part of the type cache for more difficult types - assign UIDs earlier so they can't change after cache insertion
…hat JuliaLang#10380 is merged and it works & can be tested
I have only just barely begun to implement this, but I'm filing this early to keep everybody apprised of the new design. This is my current pick for highest-priority breaking change to system internals for 0.4.
Summary of the approach:
SimpleVector
. This way many internal things can keep using the same representation (at least for a while).DataType
s, andDataType
will change very littlejl_is_tuple
andjl_is_tuple_type
.jl_typeof
andjl_is_type
are now much simpler.jl_tuple
are generally changed tojl_sv
(for SimpleVector)jl_null
is changed tojl_emptytuple
andjl_emptysv
jl_fieldref
Vararg
type is replaced with a boolean flag inDataType
Syntax changes:
{}
(Type,Type)
to{Type,Type}
, eventually have it return a tuple of types instead(Type...)
to{Type...}
, eventually have it splat insteadPlanned follow-on changes:
NTuple
a concrete type, for efficiently handling large homogeneous tuplesAddressed issues:
#8470 - use {} for tuple types
#4869 - splatting in tuple construction
#7941 - Towards array nirvana
#3440 - optimization tracker
Related issues:
#7568 - WIP: implementation of fixed-size arrays
#2299 - SIMD types