top | item 45059519

(no title)

Aardappel | 6 months ago

Yes, its somewhat similar, monomorphic specialization.

I am sure it has some limitations, but it is pretty powerful, it can even do things C++ can't, like have a type error in a branch that in the current specialization is never executed doesn't count as a type error :)

There's no FPL style pattern matching. It can do a switch case on types (the various subclasses of a base class) but only 1 level, i.e. can't match against type of members. That could still be added, just personally rarely have use for it.

discuss

order

tines|6 months ago

> like have a type error in a branch that in the current specialization is never executed doesn't count as a type error

I’ve struggled with my feelings on this even to the extent that C++ allows it, because while it is flexible, it can also hide errors in libraries that will only blow up when used in very specific ways.

Aardappel|6 months ago

Yes, that is a downside, but when you write very generic code being limited in what code you can write because it has to typecheck even for types that it doesn't apply to is one of the more frustrating things of doing this in C++ and other languages.