4 ms·
doesn't every statically typed imperative language do this, and recommend it?
by riffraff 13y ago
doesn't every statically typed imperative language do this, and recommend it?
- drdaeman 13y agoNot to my knowledge. C++ and Java are statically typed and they, as far as I know, don't have distinction between string interface and implementation, just a standard string type. You can't make your own string implementation and make others (given that - would it exist - they use standard string interface) transparently accept them instead of language's standard string implementation. Even Haskell (with standard Prelude) doesn't have a readily available and widely accepted typeclass for strings. As String is just an alias to [Char], if library writer used that, they won't accept, say, Data.Text (I know, it's a bit distinct thing, but...)
- riffraff 13y agoI was referring to "efforts to separate a type from its implementations", not String specifically, and thinking of containers & co. Although, for example, even java has CharSequence which only gives you access to codepoints in a char sequence, you can inherit from that and create your own.
- agravier 13y agoYou are right. It's interesting that I didn't think of it, probably because switching implementations in compiled languages is often less trivial, and I don't remember doing it. Actually, are there many alternative implementations of, say, the C++ STL?