Skip to main content

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
5 votes
3 answers
900 views

How are existential types different from Rust's traits?

I am investigating ways to add some form of abstract data types to a toy language. I was reading Graydon Hoare's The Rust I Wanted Had No Future, in which he talks about existential types. I have not ...
Jonas's user avatar
  • 501
4 votes
4 answers
418 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,840
7 votes
1 answer
402 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
734 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
  • 1,236
8 votes
2 answers
1k 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,668
11 votes
3 answers
1k 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's user avatar
  • 4,572