Stream: ideas

Topic: Records and Dicts


view this post on Zulip Aurélien Geron (Sep 06 2026 at 21:34):

Somewhat of a radical idea this morning, and likely one that has already been discussed and rejected before, but I couldn't find the discussions: since records are basically tuples with named fields, why not use the tuple syntax (with parentheses) for records, which would free up the curly bracket syntax for Dict and Set literals?

For example:

bart = (first_name: "Bart", age: 10)
dict = {"one": 1, "pi": 3.14}
set = {1, 3, 5, 7}

For empty Dict or Set, we could do like Python and assume {} is an empty Dict (since Dict is more frequently used than Set), or we could have some syntax like {:} for an empty Dict.

empty_record = ()
empty_dict = {}
empty_set = Set.empty()

# or

empty_record = ()
empty_dict = {:}
empty_set = {}

Pros:

Cons:

view this post on Zulip Richard Feldman (Sep 06 2026 at 21:52):

I'm curious about making list and record literals be flexible the way string an number literals are

view this post on Zulip Richard Feldman (Sep 06 2026 at 21:53):

so maybe you could write dictionaries as like { SomeTag: "blah", Another: "etc" }

view this post on Zulip Richard Feldman (Sep 06 2026 at 21:53):

and sets using square brackets

view this post on Zulip Richard Feldman (Sep 06 2026 at 21:53):

and then it would work for any userspace-defined custom collection type too

view this post on Zulip Aurélien Geron (Sep 06 2026 at 21:54):

Oooh, interesting, I hadn't considered that

view this post on Zulip Aurélien Geron (Sep 06 2026 at 21:56):

So {one: 1, pi: 3.14} could either be a Dict or a record. I suppose it would default to record?
But {"one": 1, "pi": 3.14} would have to be a Dict, right?

view this post on Zulip Richard Feldman (Sep 06 2026 at 22:50):

I think it would be { one: 1 } is a record and { (one): 1 } would be custom

view this post on Zulip Richard Feldman (Sep 06 2026 at 23:18):

and then you can put whatever expr you want in there to evaluate the key

view this post on Zulip Richard Feldman (Sep 06 2026 at 23:18):

and you don't need the parens for other literals like 1 and "foo"

view this post on Zulip Aurélien Geron (Sep 06 2026 at 23:31):

I'm not sure I understand. Would this work?

x = "one"
{ (x): 1, "two": 2 }

view this post on Zulip Richard Feldman (Sep 06 2026 at 23:59):

that's the idea!

view this post on Zulip Luke Boswell (Sep 07 2026 at 01:22):

it's a massive change for users

It's non-breaking though right? like we aren't removing the helpers are we? this is a new literal syntax

view this post on Zulip Luke Boswell (Sep 07 2026 at 01:22):

Nvm, I guess it is for {} and () have new meaning -- and the records look totally different :sweat_smile:


Last updated: Sep 24 2026 at 15:59 UTC