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

C-CTOR: incorrect usage of term "method" #274

Open
jnuss opened this issue Sep 29, 2023 · 2 comments
Open

C-CTOR: incorrect usage of term "method" #274

jnuss opened this issue Sep 29, 2023 · 2 comments

Comments

@jnuss
Copy link

jnuss commented Sep 29, 2023

The C-CTOR guideline states:

Constructors are static, inherent methods (C-CCTOR)
...
Constructors are static (no self) inherent methods for the type that they construct...

However, this is a contradiction since a "method" is described in the reference like so:

"Associated functions whose first parameter is named self are called methods..."

The API guidelines should use consistent terminology as the reference. It is proposed that the incorrect "method" terminology be replaced with the correct "associated function" terminology.

In summary, an idiomatic new() constructor is definitely not called a method.

@jnuss
Copy link
Author

jnuss commented Sep 29, 2023

Unfortunately there is another inconsistency in the ecosystem - online docs refer to all associated functions as methods: e.g. https://doc.rust-lang.org/std/boxed/struct.Box.html#method.new

What is considered the correct definition?

@jnuss
Copy link
Author

jnuss commented Sep 29, 2023

The Rust book appears to agree with the reference:

All functions defined within an impl block are called associated functions because they’re associated with the type named after the impl. We can define associated functions that don’t have self as their first parameter (and thus are not methods) because they don’t need an instance of the type to work with.

i.e. one more bit of evidence that the API guideline is using incorrect terminology

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant