5 ms·
Basically, before this you couldn't have generic types in traits, like this: trait X { type Y<Z>; } You couldn't express "a thing that contain
by unsafecast 4y ago
Basically, before this you couldn't have generic types in traits, like this:
trait X {
type Y<Z>;
}
You couldn't express "a thing that contains another thing" in one of those type expressions before, and also use the contained type. It's needed for Mappable, because it's an abstraction over the concept of modifying a value inside a container.
IMO the implementation that they have is a bit obtuse, but I don't know if you can fit something better in this language.
- wisnoskij 4y agoI really wonder about the usefulness of implementing a language feature to reduce the need to copy paste in an editor.
- mcronce 4y agoGenerics are a language feature to reduce the need to copy and paste in an editor. For that matter, functions are a language feature to reduce the need to copy and paste in an editor.
- wtetzner 4y agoReally? You don't see the problem with trying to maintain code that's been copy-pasted everywhere with slight differences? Doesn't it seem easier to maintain one implementation of something than N implementations?
- cercatrova 4y agoIsn't that basically all language features? I could also write print("Hello") print("Hello2") print("Hello3") print("Hello4") print("Hello5") (which I partially copy-pasted above) but I use a for-loop instead.
- pyrale 4y agoAs a library maintainer, you can't copy-paste a line for a type that isn't written yet. As a library user, you can't copy-paste a line for a type you just created in a library you don't maintain. Being able to do what you describe lets a maintainer create an interface for all the future types that satisfy given requirements.