solidity icon indicating copy to clipboard operation
solidity copied to clipboard

`payable` declaration defaults function to `public` visibility

Open z0r0z opened this issue 1 year ago • 2 comments

Seems simple and cool to me without losing anything afaik. I think this is what has already changed for constructor()?

z0r0z avatar Jan 23 '24 08:01 z0r0z

Hi @z0r0z, thanks for the question. However, the payable modifier can also be applied to functions with external visibility. So, I don't see a clear advantage in not explicitly stating it in the function declaration.

I think this is what has already changed for constructor()?

Not really, since Solidity version 0.7.0, the function visibility is no longer required for constructors (neither public nor internal). However, note that constructors are not payable by default; you need to explicitly declare them as payable.

r0qs avatar Jan 24 '24 03:01 r0qs

thanks for your clarifications and thoughts @r0qs. I think the idea I propose more is that by default anything that is payable be made public as a syntactic sugar. It sort of works with the idea that you can make a constructor payable, and it is public by default. But I appreciate the tension against the fact that external is also optionally payable.

z0r0z avatar Jan 24 '24 08:01 z0r0z

This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.

github-actions[bot] avatar Apr 23 '24 12:04 github-actions[bot]

Hi everyone! This issue has been automatically closed due to inactivity. If you think this issue is still relevant in the latest Solidity version and you have something to contribute, feel free to reopen. However, unless the issue is a concrete proposal that can be implemented, we recommend starting a language discussion on the forum instead.

github-actions[bot] avatar May 01 '24 12:05 github-actions[bot]