|
|
|
|
|
by thrashh
1425 days ago
|
|
You can probably do it trivially in any language with operator overloading or a very expressive type system However you would also probably want a language with some syntactic sugar that let users use your special string type easily otherwise the burden on users will be too high |
|
In the instance under discussion in that section of the book I'm referencing, allowing the user to instantiate the special string type was precisely the behavior intended to avoid. The idea being that in the following three examples, the first succeeds and the rest fail at compile time: