Skip to content

Conversation

zygoloid
Copy link
Contributor

@zygoloid zygoloid commented Sep 12, 2025

Switch to using a pair of MaybeUnformed(T) and a bool as the normal representation for Optional(T). When T is a pointer type, add a customized representation that uses MaybeUnformed(T*), with a null representation used for absent values.

@zygoloid zygoloid force-pushed the optional-storage-customization branch from 383c09a to 4fe2900 Compare September 30, 2025 01:16
@zygoloid zygoloid force-pushed the optional-storage-customization branch from 4fe2900 to d57eedb Compare October 13, 2025 23:58
Use a pair of `MaybeUnformed(T)` and `bool` by default. When `T` is a
pointer type, store just a `MaybeUnformed(T*)`, and use its unformed
null state for an absent pointer value.
@zygoloid zygoloid force-pushed the optional-storage-customization branch from d57eedb to 6320c00 Compare October 14, 2025 19:27
@zygoloid zygoloid marked this pull request as ready for review October 14, 2025 19:28
@zygoloid zygoloid requested a review from a team as a code owner October 14, 2025 19:28
@zygoloid zygoloid requested review from dwblaikie and removed request for a team October 14, 2025 19:28
Copy link
Contributor

@dwblaikie dwblaikie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't have enough of dtors working to figure out how to we'll destroy MaybeUnformed things/Optional(T)s?

@zygoloid zygoloid added this pull request to the merge queue Oct 15, 2025
Merged via the queue into carbon-language:trunk with commit 851da43 Oct 15, 2025
15 of 18 checks passed
@zygoloid zygoloid deleted the optional-storage-customization branch October 15, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants