Re:Python Type Hints – *args and **kwargs
by throwaway2037 on Monday August 28, 2023 @12:15AM
(#37289687)
Are traits and mixins the same? If not, can you please provide a trivial example. It would be useful to better understand what you mean. When I was very young, learning C++, I thought multiple inheritance was so cool. Now, I know it is like sleeping in the open jaws of a saltwater croc.
[ Parent
| on HN ]
Re:Python Type Hints – *args and **kwargs
by dontlaugh on Monday August 28, 2023 @06:17AM
(#37291964)
Traits as in the original Smalltalk research, Rust traits or Haskell type classes are like interfaces, but only when in scope. So until you import a trait, its implementation on various types isn’t visible.
This makes it possible to safely make a new trait and implement it on a built in type (like giving int a method) without the chance of another unrelated use of the type accidentally using what this trait provides.