Questions tagged [interfaces]

Use this tag for questions about interfaces as a nominal typing feature, declared types that primarily contain method headers and that other classes or types can incorporate. Do not use for questions about user interfaces.

Filter by
Sorted by
Tagged with
4 votes
4 answers
317 views

Is it meaningful to disallow member variables in interfaces?

In an object oriented language with single inheritance, there is often the concept "interface", separate from classes, as a replacement of what would otherwise require multiple inheritance. ...
user23013's user avatar
  • 2,190
6 votes
1 answer
315 views

How to design interfaces to mimic haskell-like type classes in an object oriented language?

A problem I sometimes run into when using a language like TypeScript or C# is how they lack a perfect analogue to Haskell's typeclasses. Let's use Haskell's Functor ...
Kilian Kilmister's user avatar
11 votes
1 answer
477 views

Typeclasses, traits, interfaces, protocols: is there any consistent terminology?

Many languages have some form of expressing "user-defined duck typing": defining a type by its behavior, rather than anything about the structure or data of an instance of the type itself. ...
apropos's user avatar
  • 897
6 votes
2 answers
906 views

What are the downsides of having no syntactic sugar for data collections?

For example, Python has lists, sets and dictionaries as language-level primitives that can be constructed using syntactic sugar [1,2,3], {'a': 1, 'b': 2} while Java ...
kouta-kun's user avatar
  • 1,339
10 votes
3 answers
553 views

What are the pros and cons of traits in comparison with interfaces?

In Rust, structs and enums may implement any number of traits, which specify certain functions. When a struct/enum implements a trait, this is where the functions are defined: ...
Rydwolf Programs's user avatar