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

> Why would you need operator overloading in a low-level language?

Have you ever heard of matrices and vectors? You need them in a lot of DSP (digital signal processing) applications, like audio and video filters, or in 3D graphics. Being able to write

    x = m * y
instead of

    x = m.vector_mult(y)
makes life so much more pleasant.


In Zig you write libraries that should be explicit and maintainable.


    x = m * y
is even more explicit than

    x = m.vector_mult(y)
because the * operator is side-effect free by convention, while a method like vector_mult() might or might not be mutating (i.e., it could work like the *= assignment operator).




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

Search: