Stream: compiler development

Topic: Str.inspect record


view this post on Zulip Anton (May 19 2026 at 15:13):

In which field order should Str.inspect print a record, same as definition, or alphabetical or something else?

view this post on Zulip Ian McLerran (May 19 2026 at 15:44):

My personal preference would be same as definition, but I wouldn't pitch a fit about alphabetic order lol.

view this post on Zulip Prokop Randacek (May 19 2026 at 15:47):

same order as definition is what i would expect as a user. but if they get sorted then changing the order of the fields probably can't be a breaking change :thinking:

view this post on Zulip Richard Feldman (May 20 2026 at 01:10):

same order is tricky

view this post on Zulip Richard Feldman (May 20 2026 at 01:10):

I think it has to be alphabetical for anonymous records (although nominal can use definition)

view this post on Zulip Richard Feldman (May 20 2026 at 01:12):

I think to get it same order we'd need to change type unification to have aliases unify with records in a way where the alias's order "wins"

view this post on Zulip Richard Feldman (May 20 2026 at 01:13):

but the problem there is that now you can potentially have multiple aliases unifying successfully with the same record, so you need a way to decide which one wins

view this post on Zulip Richard Feldman (May 20 2026 at 01:14):

at which point you can get into territory of running the same build twice and getting a different program based on thread race conditions etc.

view this post on Zulip Richard Feldman (May 20 2026 at 01:15):

so I think it's better to just go with alphabetical for anonymous records

view this post on Zulip Richard Feldman (May 20 2026 at 01:15):

for nominal records definition should be no problem

view this post on Zulip Jared Ramirez (May 20 2026 at 01:25):

same order might be hard in general, because unification must sort records fields alphabetically (so it knows which fields belong to record a, which to record b, and which are in both, then has those groups “flow” into the records extensible variables)

view this post on Zulip Richard Feldman (May 20 2026 at 02:06):

oh yeah also true


Last updated: May 23 2026 at 12:51 UTC