Stream: ideas

Topic: "method" definition


view this post on Zulip Richard Feldman (Jul 14 2025 at 22:06):

What if we officially defined "methods" as a thing in Roc, and defined them something like the following?

In Roc, a method is a function which is:
* Exposed by a module
* Takes a nominal type as its first argument
* That nominal type is defined in the same module that exposes the function

(except maybe more concisely/eloquently)

view this post on Zulip Brendan Hansknecht (Jul 14 2025 at 22:10):

To what end? Just to explain static dispatch more easily?

view this post on Zulip Richard Feldman (Jul 14 2025 at 22:53):

yeah and like we keep ending up using the term anyway in practice

view this post on Zulip Richard Feldman (Jul 14 2025 at 22:54):

it feels like trying to get people to not say it will be a pointless battle, so seems more useful to embrace it and make a clear definition so everyone can be on the same page about what it means and implies

view this post on Zulip Luke Boswell (Jul 14 2025 at 23:21):

Sound good. Something something semantics in imperative clothing :laughing:

view this post on Zulip Brendan Hansknecht (Jul 15 2025 at 00:08):

Sure

view this post on Zulip Kiryl Dziamura (Jul 15 2025 at 02:05):

How about naming all functions exposed by the type module "methods"? Since you can call any of them on type: Num.decode(bytes). So maybe instance methods are first arg methods and type methods are module exports? Type module differs from other modules in the way that it also represents type and constructor. It's not only a namespace so its exports feel different, at least for me.

But I don't really care. I think terminology should come naturally so it's better to observe and embrace as it was already mentioned.


Last updated: Jun 16 2026 at 16:19 UTC