Stream: ideas

Topic: Adding support for Vector/Matrix Math


view this post on Zulip Jonas (Dec 19 2024 at 08:22):

Hey, i really like how languages like Odin support Vector Math, i mean having Math Operator to Update Array Indizes. I don't know if it fits Roc but i just wanted to throw out the idea.

view this post on Zulip Norbert Hajagos (Dec 19 2024 at 08:48):

There have been quiet a lot of discussions about it. Here is the most recent topic on it #ideas > static dispatch - operator desugaring to methods . Roc's historically been reserved to add operator overloading so that + would work on your custom matrix types, because it's easy to misuse that feature. But we all agree that it is nice for matrices, so (according to the plan) defining a plus function on a custom type will allow such thing. It's just that the type will have to be nominal (have to be declared with a name in a separate module, not created on a whim out of literals)

view this post on Zulip Sam Mohr (Dec 19 2024 at 08:53):

Also, what @Norbert Hajagos would work for adding custom matrices, but without indexing syntax. E.g. even without custom data structures, there's no such thing is list[index] in Roc

view this post on Zulip Sam Mohr (Dec 19 2024 at 08:55):

@Jonas could you give an example of what you'd want to be able to do? I presume list[index] += 3 is what you mean

view this post on Zulip Norbert Hajagos (Dec 19 2024 at 08:58):

Ahh yes, no vec[idx] operator, since List is the base "array-like" collection, which isn't fix sized and there's always a bounds check, so it returns a result. We have no arrays, only tuples, but they are more like structs.

view this post on Zulip Jonas (Dec 19 2024 at 09:00):

@Sam Mohr yes

view this post on Zulip Brendan Hansknecht (Dec 19 2024 at 15:25):

Also, roc has no support for missing types. So no matrix plus scalar. I guess we could add it with static dispatch, but that is a separate idea


Last updated: Jun 16 2026 at 16:19 UTC