-
-
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
[doc] rename outer-only constructors? #23022
Comments
Where does it say it is an outer constructor? |
Judging from your title, there is still some confusion. The documentation at that point is not saying that this definition:
is an "outer-only constructor". The role of that function is described in this passage:
(emphasis mine). Defining this "inside" the type definition block means this is an "inner" constructor. What "outer-only constructors" refers to in that section is this: If you write something like the above, this "suppresses generation of default constructors"; if you don't, generation of default constructors takes place normally. And as per the bit a couple of subsections above that passage, this involves both implicit inner and outer constructors, such as:
Therefore, if a "blocking" explicit inner constructor has been provided, these implicit inner constructors are no longer available. You can't use them. And for that reason, you can rely on "outer constructors only" (hence the title of the section) of your creation, that necessarily act as wrappers to the explicit inner constructor you defined. Therefore, in the SummedArray example, the presence of that inner constructor, prevents you from being able to create an instance of type |
So there are no outer-only constructor examples within that section? ✅ A women-only [space] is a physical [area] where only women are allowed. ✅ The English-only [movement] is a political [movement] for the use of only the English language in |
No there are not. :) There's no such thing as an "outer-only constructor". The point of that title is simply to point out that "there are cases where the user of a type cannot rely on default inner constructors to create instances for that type, because these have been explicitly blocked by the presence of an explicit inner constructor". And therefore the user can only call that explicit constructor, or create more outer constructors that necessarily involve calling the explicit inner constructor within their function definition. But that's their only option; the option to use the default inner constructors simply doesn't exist. (hence, I guess, why they called the section "outer-only"). |
@tpapastylianou After some investigation, I find something interesting in this post #8135 (comment) :
It seems the original idea is to make "outer-only" constructor an truly outer constructor. @fredrikekre maybe here ;) |
Well, I may be wrong in my interpretation of that thread, but again, I think this is not the case, and the confusion again is produced from using "outer" and "inner" in different contexts. The pertinent comment setting the context in that thread is this one, i.e. the fact that the syntax "Foo{N}" means different things in the context of a type definition and its inner constructor vs in the context of an outer constructor definition. I.e. one acts as a 'concrete' method on a parametric (but fully specialised at the time of instantiation) type, the other acts as a parametric method where the parameter will essentially dictate which specialised inner constructor to call -- subtle difference but not quite the same thing. But, Jeff is saying there could conceivably be a way to create an inner constructor in a hacky way (by overloading the In any case, I don't think the two threads are that related, apart from the fact that in both there is potential for confusion because the distinction between default vs explicit is never made clear :) |
However, @JeffBezanson gave another definition of inner/outer constructor in the thread below:
Following this definition(forget the definition concerning type block in the doc), you'll find what I said in that SO post is actually right. I hadn't read this definition before, I made the deduction from the outputs of
if the assumption holds true(i.e. like Jeff said "An outer constructor will just be a method of Type{A}"), obviously the definition of inner constructors from the doc should be corrected. That's why I asked the question -- What on earth is an inner constructor? The point here is simply a naming thing, using which definition depends on what the original author thought. The outer-only constructor section is written by Jeff, let's wait for him to answer whether
is an outer constructor or not 😕😕😕 |
@tpapastylianou As @StefanKarpinski said in this post:
the ambiguity of |
As discussed here, the outer-only constructor
SummedArray(a::Vector{T})
is actually an inner constructor. Shall we pick up a better name or add some additional info for clarification?The text was updated successfully, but these errors were encountered: