Remix.run Logo
badtuple 2 days ago

Interfaces can still be expressed using vtables. You just have to write the vtable yourself rather than have the language do it for you.

Also, Zig's tagged unions (enums with payloads in Rust) are really ergonomic and often what you want instead of interfaces. Alot of languages that use interfaces simply don't expose a good way of doing it so everyone reaches for interfaces by default. But if you don't need an actual interface then this way you don't even have to pay the cost of runtime dynamic dispatch.

redrobein 2 days ago | parent [-]

Are there any plans to add syntax sugar for interacting with vtables?

lenkite 2 days ago | parent | next [-]

Wish we could bribe Andrew Kelley to add a built-in for this. There are only a couple of regular ways that everyone creates these vtables. Might as well just standardize it.

sali0 a day ago | parent [-]

I feel like a std lib module would be sufficient.

metaltyphoon 2 days ago | parent | prev [-]

Sadly no, as fas as I'm aware. I can't think of creating vtables manually every time I need to create interfaces, I guess Zig is not for me.

slopinthebag 2 days ago | parent [-]

Yeah I don't understand why a language cannot automate something that routine and boilerplate-y.

Oh well, people like it so I won't judge, I'm happy we have choices for what languages we use. Just wish people would choose safe ones :/