random order of initialization of records with named fields

1 view
Skip to first unread message

Dambaev Alexander

unread,
Feb 21, 2026, 7:42:15 AM (7 days ago) Feb 21
to ats-lan...@googlegroups.com
Hi,

in ATS2 we can have records with named fields:

```
typedef my_type_t = @{ field1 = int, field2 = double}
```

but using such named fields in a wrong order is a compile time error:

```
implement main0() = {
  val v1:my_type_t = @{ field2 = 1.0, field1 = 2}:my_type_t
}
```

it will still try to produce `@{ 1.0, 2}` instead of expected `@{ 2, 1.0}`

Will ATS3 handle such use case better?

Will there be record update support as well? Currently, we have to reconstruct the whole record in case of 1 field update. For complex records it can be cumbersome.




Hongwei Xi

unread,
Feb 21, 2026, 8:54:24 AM (7 days ago) Feb 21
to ats-lan...@googlegroups.com
Yes, I am aware of this issue. It will be taken care of in ATS3.
For an expression like @{b=e1, a=e2}, there are two natural interpretations:

let x1 = e1 in let x2 = e2 in @{a=x2, b=x1}
let x2 = e2 in let x1 = e1 in @{a=x2, b=x1} // This is the interpretation I intend to implement

>> Will there be record update support as well?

Yes. I have also outlined a lens library for ATS3. We will see.


--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KwndP7pCNU8pF2CEHnGNUPoxFA2njRVnwU2cNHQjoU%2B8w%40mail.gmail.com.

Hongwei Xi

unread,
Feb 21, 2026, 10:07:23 AM (7 days ago) Feb 21
to ats-lan...@googlegroups.com
I got it wrong:

>> let x1 = e1 in let x2 = e2 in @{a=x2, b=x1}
>> let x2 = e2 in let x1 = e1 in @{a=x2, b=x1} // This is the interpretation I intend to implement

What is implemented is the first interpretation:  let x1 = e1 in let x2 = e2 in @{a=x2, b=x1}

Reply all
Reply to author
Forward
0 new messages