-
-
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
Feature Request: allow default values for unspecified type parameters #4859
Comments
This is one reason some types (like
and then you almost have what you want. This is a difficult change, since typically type parameters can be left "unspecialized" by leaving them off (e.g. |
This is only when used, e.g., in function signatures, right? Ideally, I'd like to be able to keep this behavior (so that someone could pass an ordered or unordered |
Currently there is no distinction between type construction inside function signatures and anywhere else. |
If |
For construction, I can't leave a type unspecialized, can I? julia> type TestType{A,B} end
julia> TestType{Int,Int}()
TestType{Int64,Int64}()
julia> TestType{Int}()
ERROR: type cannot be constructed |
I would be quite happy with being able to specify |
It is possible to make a partially-specialized type like |
I was going to write something along the same lines, but you beat me to it. |
For my modified |
But |
The point I was trying to make is that I don't believe this is defined explicitly as such (with no parameters), but only as the default type constructor. |
#1470 will make it possible to define constructors for partially-specified types, which seems to be the best way to resolve this. |
In #4038, I updated
Dict
to have a third type parameter, specifying whether theDict
should beOrdered
orUnordered
[1]. This allows one to create anOrderedDict
withHowever, in order to create a normal
Dict
, I also need to specifyUnordered
:I'd like to be able to simply specify
Dict{String,Int}()
, so that existing code continues to work unchanged.This would seem to require the ability to specify a default value for a type parameter, or have it default to
Any
. Possible?CC: @JeffBezanson, @StefanKarpinski
[1] It's irrelevant here, but
Ordered
is a type alias forInt64
, andUnordered
is a type alias forNothing
.The text was updated successfully, but these errors were encountered: