lambdaworks icon indicating copy to clipboard operation
lambdaworks copied to clipboard

Rename traits

Open jrchatruc opened this issue 2 years ago • 5 comments

There is currently a naming convention on traits that they are supposed to start with something like Is or Has. We should get rid of it

jrchatruc avatar Feb 09 '23 13:02 jrchatruc

With has there shouldn't be any problems. But with is, if we just remove them there will be a name collision between the concrete instantiation and the trait. So this should be taken in account for the refactor

MauroToscano avatar Feb 09 '23 13:02 MauroToscano

Fwiw, naming the trait and the struct the same thing isn't the worst.

You could always partially or fully qualify the trait. For example, math::traits::Field, which is fine as you likely only use the trait in one place per file.

You can also do a renaming import: use math::traits::Field as FieldTrait.

Both are fine for clarity's sake and avoid awkward naming conventions.

gluax avatar Feb 10 '23 01:02 gluax

Fwiw, naming the trait and the struct the same thing isn't the worst.

You could always partially or fully qualify the trait. For example, math::traits::Field, which is fine as you likely only use the trait in one place per file.

You can also do a renaming import: use math::traits::Field as FieldTrait.

Both are fine for clarity's sake and avoid awkward naming conventions.

I agree with this, we should take a similar approach.

ilitteri avatar Feb 10 '23 11:02 ilitteri

The naming convention we used is: "Nouns only for structs". Every name that is not a noun is allowed for a trait. For example adjectives, verbs, or things like "IsSomething" are all allowed. The "Is" or "Has" prefix is not mandatory, but we found it more declarative in some cases, specially when you see variable types: where F: IsField.

In my opinion it would be good if we have some kind of naming convention, it doesn't have to be this one necessarily.

ajgara avatar Feb 10 '23 13:02 ajgara

The naming convention we used is: "Nouns only for structs". Every name that is not a noun is allowed for a trait. For example adjectives, verbs, or things like "IsSomething" are all allowed. The "Is" or "Has" prefix is not mandatory, but we found it more declarative in some cases, specially when you see variable types: where F: IsField.

In my opinion it would be good if we have some kind of naming convention, it doesn't have to be this one necessarily.

I think the "Is" or "Has" or any prefix for that matter feels very un-rust-like. I feel in my rust experience most libraries would prefer to pub mod trait and qualify the trait or import rename.

gluax avatar Feb 21 '23 23:02 gluax