Hacker News new | past | comments | ask | show | jobs | submit login

> Is this any different from generics?

Depends on the way generics is implemented in the language you're talking about.

In D, for example, Zig's `anytype` is equivalent to using a template type `T` in D without any constraints. The result is the same: the implementation can call any method, but it must exist when the type is instantiated (on an invocation).

Example in D:

https://run.dlang.io/?compiler=dmd&args=-unittest&source=str...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: