Stream: ideas

Topic: Optional record field syntax


view this post on Zulip Luke Boswell (Sep 17 2026 at 03:33):

@Aurélien Geron mentioned this in the other thread... I thought I'd pull it into another thread to avoid overloading that one (which proposed a more significant change). #beginners > Cannot add fields to a record with default fields @ 💬

a = { foo: 123, bar: 456 }          # For asthetic reasons ...
a = { foo: 123, bar:? Ok(456) }     # I prefer this
a = { foo: 123, bar ?: Ok(456) }    # Over this

view this post on Zulip Luke Boswell (Sep 17 2026 at 03:51):

Jared Ramirez said:

i also found :? more intuitive when originally working on this, but i think Richard preferred ?: because it’s a more common operator in other languages! (the elvis operator i think it is called)

view this post on Zulip Luke Boswell (Sep 17 2026 at 03:56):

I think I found the issue with my proposal...

view this post on Zulip Luke Boswell (Sep 17 2026 at 03:57):

# usage
{ field: 0.0 }
{ optional?: 0.0 }
{ default: 0.0 }

view this post on Zulip Luke Boswell (Sep 17 2026 at 04:00):

When you use it should the ? sit with the field identifier, or would it be even more strange.

I would summaries by saying I think the current approach is nicer in the case where we have no type annotations.


Last updated: Sep 24 2026 at 15:59 UTC