roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.39k stars 309 forks source link

Using `{ a, b, ..other }` in Addition to Current &-Based Update Syntax #7097

Open smores56 opened 1 month ago

smores56 commented 1 month ago

We currently use the following syntax for record updates:

updatedRecord = { record & foo: 123, bar: "abc" }

Which can be short-handed for a single field with record |> &foo 123.

We also want to support a different syntax:

updatedRecord = { foo: 123, bar: "abc", ..record } 

Since we have two existing syntaxes for record updates that both use the &, if we were to remove the old syntax now, we'd still have the &foo shorthand syntax. As such, we should support both syntaxes, and after looking at how the code falls out, pick a syntax based on whether we prefer the & consistency, or ..record consistency with the other ..-based changes being made in https://github.com/roc-lang/roc/issues/7091.

hrishisd commented 1 week ago

I'd like to give this a shot!

smores56 commented 1 week ago

Sounds good to me! This should help unlock some other stuff, too. I'll assign it to you and label it.