Stream: ideas

Topic: ✔ Argument syntax given braces


view this post on Zulip Niclas Ahden (Feb 12 2025 at 18:58):

Given #ideas > braces syntax, could we improve the argument syntax (||)?

E.g. using \:

\foo, bar {
    look_ma!(foo, bar)
}
\foo, bar { "${foo} in the name of ${bar}" }

|| is familiar to many through Ruby and Rust. It also delimits the args clearly (although we now have { as a known delimiter after args anyway).

\ is known as lambda to many some, it's one character instead of two (and now we have a known delimiter after args {), and unlike | it doesn't require a modifier to type on US (and many other?) keyboard layouts.

I don't feel strongly about this, but realized that there's a new opportunity here given {.

view this post on Zulip Sam Mohr (Feb 12 2025 at 19:04):

I don't think \ is known as lambda to many, that was a discussion point (discussion in giant air quotes) on the HN thread about the Zig rewrite

view this post on Zulip Sam Mohr (Feb 12 2025 at 19:05):

Also, lambdas might not have braces if they are one liners, so we'd maybe write this with your proposed syntax: \foo, bar look_ma!(...)

view this post on Zulip Niclas Ahden (Feb 12 2025 at 19:06):

mmm, wouldn't that be something? ;)

Nah, that's true, I was thinking that braces are used for one-liners too

view this post on Zulip Sam Mohr (Feb 12 2025 at 19:07):

It wouldn't be great to need braces for list.map(|x| { x * 2 }), that's just more noise

view this post on Zulip Notification Bot (Feb 12 2025 at 19:14):

Niclas Ahden has marked this topic as resolved.


Last updated: Jun 16 2026 at 16:19 UTC