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

allow constructor names in substrate #1035

Merged

Conversation

xermicus
Copy link
Contributor

@xermicus xermicus commented Oct 7, 2022

This changes a few things regarding constructor names for the substrate target:

  • Constructors may now have a name, like functions.
  • If they have no name, new will be used automatically.
    • It is a convention to call "constructors" new in Rust too
    • new is a reserved keyword in Solidity, so you can't write a function called new anyways (prevents conflicts)
  • It works nicely together with the function name mangling.

To make instantiation of ink! (Substrate) contracts possible in the future, I think generating interface files is the better solution than changing our syntax to allow it.

Signed-off-by: Cyrill Leutwiler <[email protected]>
Signed-off-by: Cyrill Leutwiler <[email protected]>
@xermicus xermicus marked this pull request as ready for review October 7, 2022 15:02
@xermicus xermicus requested a review from seanyoung as a code owner October 7, 2022 15:02
@xermicus xermicus requested a review from LucasSte October 7, 2022 15:02
@xermicus xermicus added the polkadot Concerns the Polkadot target label Oct 7, 2022
Copy link
Contributor

@seanyoung seanyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor documentation comments. Looks good!

src/sema/contracts.rs Outdated Show resolved Hide resolved
docs/language/contracts.rst Outdated Show resolved Hide resolved
docs/language/contracts.rst Outdated Show resolved Hide resolved
docs/language/contracts.rst Show resolved Hide resolved
Signed-off-by: Cyrill Leutwiler <[email protected]>
docs/language/contracts.rst Outdated Show resolved Hide resolved
docs/targets/substrate.rst Outdated Show resolved Hide resolved
xermicus and others added 2 commits October 10, 2022 08:20
Co-authored-by: Lucas Steuernagel <[email protected]>
Signed-off-by: Cyrill Leutwiler <[email protected]>
Co-authored-by: Lucas Steuernagel <[email protected]>
Signed-off-by: Cyrill Leutwiler <[email protected]>
Copy link
Contributor

@LucasSte LucasSte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nitpick.

docs/language/contracts.rst Outdated Show resolved Hide resolved
@xermicus xermicus merged commit 1b724ed into hyperledger-solang:main Oct 10, 2022
@xermicus xermicus deleted the substrate-allow-constructor-names branch May 15, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polkadot Concerns the Polkadot target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants