Skip to content
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

[contract-deploy] Support multiple constructors in the same contract #4063

Closed
Tracked by #4052
spalladino opened this issue Jan 16, 2024 · 6 comments
Closed
Tracked by #4052

Comments

@spalladino
Copy link
Collaborator

spalladino commented Jan 16, 2024

As a nice-to-have, define multiple constructors in the same contract. These should all emit the same initialization nullifier. Test that, once a ctor has been called, the others cannot be called.

@rahul-kothari
Copy link
Contributor

Should this be a compile time error? If you have multiple ctors?

@spalladino
Copy link
Collaborator Author

Should this be a compile time error? If you have multiple ctors?

Not sure I understand the question. The idea is that you should be able to have multiple constructors in your code if you want, but you are only allowed to call one of them on each instance you've deployed.

@rahul-kothari
Copy link
Contributor

Ah as in whats the usecase where you are ok with having multiple constructors in one contract?

@spalladino
Copy link
Collaborator Author

Nothing you cannot do with a single constructor and a lot of conditionals, for sure. But it's pretty common for a language to support multiple constructors (though js and solidity don't). As an example, maybe having different constructors for an erc20 token, depending on whether there is initial minting or not?

@rahul-kothari
Copy link
Contributor

Actually nvm there are tons of usecases for multiple constructors. Java has this
Super useful for "default" parameters.

@spalladino
Copy link
Collaborator Author

Closing as done

@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants