-
-
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
Expand documentation on Val{T} #15729
Conversation
Thank you. |
A = fill(5.0, (3, 3)) | ||
|
||
This approach works very well: the compiler can figure out that ``A`` | ||
is an ``Array{Float64,2}`` because it know the type of the fill value |
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.
"knows" I think.
I think I would rather use this example as a demonstration of why you shouldn't make a type that depends on a value since it leads to further complication of the API later. But I agree there are a number of optimizations missing for NTuple that need to be addressed. |
Meaning, It's a hard road, though, because so much depends on knowing the dimensionality. Almost all of our indexing rules, for example. Which happen to be extraordinarily performance-sensitive. |
@@ -1237,24 +1237,15 @@ If you apply :func:`supertype` to other type objects (or non-type objects), a | |||
julia> supertype(Union{Float64,Int64}) | |||
ERROR: `supertype` has no method matching supertype(::Type{Union{Float64,Int64}}) | |||
|
|||
.. _man-val-trick: | |||
|
|||
"Value types" | |||
------------- | |||
|
|||
As one application of these ideas, Julia includes a parametric type, |
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.
Never understood what kind of "these ideas" are being referred to. I guess many people who just followed the _man-val-trick
link have the same experience.
Also, I find it a little bit confusing that Val{T}
is introduced as some sort of Julia type system quirk, whereas in fact it's just an empty immutable, and the same effect could be achieved with any user-defined type. Maybe it's worth clarifying.
Based on my experience of reading this section I would suggest a few things.
|
that's not really meaningful. there is a ordering of events such that runtime occurs after compile-time
it's not particularly slow, but
design the api so it isn't necessary |
On Sat, Apr 2, 2016 at 12:28 PM, Jameson Nash [email protected]
One of the reasons I'm using Julia (and not CUDA, C++, and Python) is that Originally I came to Julia for the macros, because they are much easier to -erik Erik Schnetter [email protected] |
Actually, in many cases, after using |
Thanks for the review comments, everyone. Very helpful. I'll merge unless additional concerns are raised. |
Also adds numerous tweaks in response to review comments.
An alternative to #15725.