Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postfix record update syntax #7226

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hrishisd
Copy link
Contributor

Adds an alternate post-fix syntax for record updates

newRecord = { foo: 123, bar: "abc", ..oldRecord } 

Closes #7097

Comment on lines +404 to +411
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RecordUpdateKind {
/// e.g. `{ oldRecord & field: newValue }`
Prefix,
/// e.g. `{ field: newValue, ..oldRecord }`
Postfix,
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of naming these DeprecatedAmpersand and NewDotSpread?

I assume the intention is to deprecate the older syntax and eventually remove, so long term these wont be required but until then it's clearer I think what they are doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can definitely clarify the naming! I'll just double-check that the intention is indeed to deprecate the older syntax. My previous impression was that the dot spread syntax was experimental.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that it's experimental in the way that most stuff in Roc is experimental. We want to unify the aesthetic of our syntax by moving types where appropriate to the new .. syntax suite, but we may throw all of it away in the future like we did with Task and camelCase and applicative record builders.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't call all of this stuff experimental, we just assume it'll be in the compiler for the time being until we remove it. The only stuff that we tend to name based on how short-lived it is would be stuff we plan to deprecate soon, like the old record builder syntax (that has since been removed), or maybe Task stuff.

So I'd just call it DeprecatedAmpersand and DotSpread myself.

@hrishisd hrishisd marked this pull request as draft November 21, 2024 15:37
@hrishisd
Copy link
Contributor Author

Sorry for the delay - just want to make some improvements that were suggested in Zulip, which is taking some time. Marked as draft for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using { a, b, ..other } in Addition to Current &-Based Update Syntax
3 participants