-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Allow constructor to be external? #4392
Comments
Your argumentation makes sense, but somehow I feel that the keywords here do not directly translate to constructors, since you call a constructor only implicitly. Using an external |
I agree the keywords are awkward; and we should avoid Maybe following is the topic to focus on and find some other keyword than
|
IMO constructor should be Recommended Remediation: Remove visibility modifier from constructor entirely (on the argument that it doesn't really make sense) or make |
Thinking more on this, I think this may currently be used for abstract classes (where they should not be instantiated directly, always derived from). I would rather see a dedicated keyword for this like |
Yep, I would second this. Even when calling I would push back a bit on the remediation though, but I think that your suggestion of using the Thanks for commenting on this! I remember learning about the difference between |
Note that constructors of base contracts are called internally, while the most derived constructor could be say do be called externally. Once we have I agree that removing visibility is probably the cleanest solution. |
Calldata data locations for all variables is tracked here: #5545 |
@Marenz remarks that there are internal types that can only be used with internal constructors. |
Cannot we loosen that so constructors can see every type in the given contract? |
I understood that the problems are internal function pointers or storage pointers. |
@Marenz can you clarify your concern here? |
It's not exactly a concern, just a point to consider: A c'tor like |
The solution I see is to require the contract to be abstract. |
Closing since external does not work with inheritance and we aim to remove visibility completely (#8162). |
One way to see is that a
public
is bothinternal
andexternal
.So why can't a constructor be
external
given that it can bepublic
?Is
public
on a constructor identical topublic
for a function? If not, should there be a different keyword than changing the meaning ofpublic
for a constructor?It would also be useful if marking a constructor
external
, prevented the contract from being inherited from.(Related but wasn't resolved in #3132)
The text was updated successfully, but these errors were encountered: