Stream: ideas

Topic: `{ ..rest } =` remaining fields capture syntax


view this post on Zulip Sam Mohr (Aug 24 2024 at 16:25):

As part of the new .. syntax proposal, we're already leaning towards using { a : Str, b : U64, ..c } as an equivalent to { a : Str, b : U64 } c, which implies c is a different record type that extends past the two existing fields. We would like to discuss what the { a, b, ..rest } = syntax would mean as a pattern capture.

The implication is one of two things, in my eyes:

  1. ..rest captures the remainder of the fields, not including a or `b
  2. ..rest captures all fields, including a and b

These are alternatives to a potential of { a, b } as record =, which achieves number 2 above without a .. operator for consistency with other as usage in Roc.

Do you like one of these options? Hate it? Have an alternative? Comments below!

Note: this is a separate discussion from the ..rest being required for open records, check the other #ideas thread for that.

view this post on Zulip Brendan Hansknecht (Aug 24 2024 at 16:56):

I think it is only reasonable to assume {a , b, ..rest } means that rest no longer contains a and b. It matches list pattern matching as well. [a, b, ..rest].

view this post on Zulip Brendan Hansknecht (Aug 24 2024 at 16:56):

As mentioned in the other thread, I don't think we should allow it. We should just support that as syntax.

view this post on Zulip Sam Mohr (Aug 24 2024 at 17:06):

If we move towards the as syntax, I still think we should do { a, b, .. } as data = to avoid issues with open records vs closed records, but that's for another thread I think

view this post on Zulip Brendan Hansknecht (Aug 24 2024 at 17:13):

Yeah, really just a question of do we concider record pattern matching open or closed by default. The thread with the { a, b, ..{} } suggests we consider record pattern matching as open by default. So it would be { a, b } as data vs { a, b, ..{} } as data for open vs closed respectively. But yeah, probably a whole other discussion to finalize those semantics

view this post on Zulip Sam Mohr (Aug 24 2024 at 18:14):

That's the conclusion we seem to have come to in the other thread


Last updated: Jun 16 2026 at 16:19 UTC