-
-
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
Deprecate similar(array, type)
in favor of similar(type, array)
?
#25441
Comments
Note that |
We define |
A difference with
rather than:
|
Since the "base case" for calling
This is not a good comparison, in 0.6 we have methods of In general, the |
Yes, the argument order is based on |
The return type wouldn't be inferred in that case, would it? |
I think recent improvements of keyword argument handling makes it possible to infer the return type.
|
Ah, this doesn't work:
|
I don't think the
My thought on #18161 is that it'll require an entirely new name in any case, so we don't need to stress too much about getting this signature backwards-compatible with a new design. |
The current argument order of the
similar
function violates the style guide on argument ordering: https://docs.julialang.org/en/latest/manual/style-guide/#Write-functions-with-argument-ordering-similar-to-Julia's-Base-1.The guideline suggests the type argument should come before the input argument not being mutated. However, methods like
similar(array, type)
(e.g.similar(zeros(10), Float32)
) are defined in Base. I think we should flip the order of these arguments to obey the guideline.I couldn't find any discussions on this topic but #18161 may be related.
The text was updated successfully, but these errors were encountered: