Stream: beginners

Topic: ✔ Shorthand for anonymous records acting as keyword args


view this post on Zulip Jonathan (Jan 22 2025 at 15:53):

Hi again, just wondering if a shorthand syntax is being/has been considered for passing a record as the only argument to a function?
I know that syntax discussion like this can be a bit of a distraction, but I just thought I should make the case for allowing (in PNC):

f{x, y}
f{x: 1, y: 2}

as sugar for

f({x, y})
f({x: 1, y: 2})

given that anonymous records are the idiomatic and only way to do named arguments.

I'm not entirely convinced, as I found the syntax in Lua a tiny bit of a surprise when I was a beginner, and have no idea how this interacts with the rest of parsing or the Roc ethos, but thought it was worth asking?

view this post on Zulip Anton (Jan 22 2025 at 15:56):

I'd like to keep it as is for simplicity but it is something we can consider some time in the future.

view this post on Zulip Jonathan (Jan 22 2025 at 15:57):

Fair enough, thanks!

view this post on Zulip Notification Bot (Jan 22 2025 at 16:52):

Jonathan has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC