Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The correctness of use the word type to refer to some language element

When we have some struct T, we usually refer to T as a type.

pub struct Player;

and we can say, the type player.

But what if it’s a trait instead?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

pub trait Player {}

is correct to refer to the trait player with the word type? Or they have another nomenclature, word or similar?

What about the enumerated types? Is that correct?

pub enum Player {
    Soccer,
    Rugby,
    Basket
}

where we can refer to the enum as the enumerated type Player, or just the type player.

>Solution :

Per Wikipedia (emphasis mine),

In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it.

As traits don’t contain values it is incorrect to call them types. As enums do it is correct to do so.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading