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

I feel like the ocaml solution would fit zigs usecase well.

In ocaml you can redefine operators... but only in the context of another module.

So if I re-define + in some module Vec3, I can do:

  Vec3.(a + b + c + d)
Or even:

  let open Vec3 in
  a + b + c + d
So there you go, no "where did the + operator come from?" questions when reading the source, and still much nicer than:

  a.add(b).add(c).add(d)
I doubt zig will change though. The language is starting to crystallize and anything that solved this challenge would be massive.


For something as simple as a vec3 type, Zig has a @Vector 'meta-type', it's quite bare bones though:

https://ziglang.org/documentation/master/#Vector




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: