Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'll try to put together a PoC a little later. I won't have time till at least this evening though, maybe later.


It's a very nontrivial amount of code to make the library that provides all of those features, even worse to do it well. Here's a PoC for one of them [0] (default implementations).

The broad theme is that other languages use keywords for traits or subclasses or whatever. In Zig, you can define libraries using the language's metapgrogramming facilities that do the same thing (or similar things).

Zig doesn't have a complete metaprogramming story yet either, which makes it harder (no custom types with custom decls, can't create a function dynamically, ...), but there are still a few options for creating something that looks like an interface.

In my mind, all the obvious solutions have something like a "template" and utilities that operate on that template. The template serves as documentation and also a hint to the LSP. Its exact semantics aren't important; they just have to match however that library decides the implementation should look.

[0] https://github.com/hmusgrave/zinter


Awesome! Nice work. I’m still astounded by what you can pull off with comptime.


Comptime is amazing. It's a new language, but I'm excited. I got my team excited too, for some fantastic benefits at work.




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

Search: