Skip to content

Syntax to add a field to the current record #312

@julianhyde

Description

@julianhyde

We have syntax to add a field, but it adds a new record. For example,

from e in emps,
    pay = e.sal + e.comm

returns elements with fields e and pay. (The e field is a record, containing all 8 fields of emps, and pay is a scalar.)

But we need a syntax to add a field to e, so that it has 9 fields (one of which is pay). Inspired by with (added in #249) which replaces a field with a new value, we could add withnew, like this:

from e in emps
    yield {e withnew pay = e.sal + e.comm}

withnew is not a great name. We should find a better word. But it's good that this can be achieved without adding a new relational operator (type of step).

Elm-like syntax

Elm has extensible records. With Elm's syntax, this example would be

from e in emps
    yield {e | pay = e.sal + e.comm}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions