You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently working on a codebase where we don't like using pointers for null values, but small types like booleans present problems with using the zero value for when it's absent. False is a perfectly valid value for a partial update of a boolean field in a larger struct.
Describe the solution you'd like
We have a custom built a generic optional value much you'd see in languages like Rust, Java, or Haskell that we'd like to use instead. I propose adding a third option to the optional configuration, something like generic, and then another configuration option much like context_type, optional_generic_type that can be used in place of pointers.
The question is whether to have the generic value without its generic parameter, or include some placeholder like optional.Value[A] or optional.Value[%].
Having this as a third option means you won't break compatibility with <1.18 unless someone opts into it.
Describe alternatives you've considered
The available alternatives of zero values, or pointers each have significant drawbacks.
Additional context
This is the full implementation of our generic optional type optional.Value, but the configuration options allow anyone else to sub their own in. Happen to open a Pull Request with the changes if you like the idea.
…lable types (#252)
This is an implementation for #251, it adds a new `"generic"` option for
the `"optional"` configuration, and a companion type
`"optional_generic_type"` which is a fully qualified type with a
placeholder `%` for the generic parameter.
Co-authored-by: Dylan R. Johnston <[email protected]>
Co-authored-by: Ben Kraft <[email protected]>
Is your feature request related to a problem? Please describe.
Currently working on a codebase where we don't like using pointers for null values, but small types like booleans present problems with using the
zero
value for when it's absent. False is a perfectly valid value for a partial update of a boolean field in a larger struct.Describe the solution you'd like
We have a custom built a generic
optional
value much you'd see in languages like Rust, Java, or Haskell that we'd like to use instead. I propose adding a third option to theoptional
configuration, something likegeneric
, and then another configuration option much likecontext_type
,optional_generic_type
that can be used in place of pointers.The question is whether to have the generic value without its generic parameter, or include some placeholder like
optional.Value[A]
oroptional.Value[%]
.Having this as a third option means you won't break compatibility with <1.18 unless someone opts into it.
Describe alternatives you've considered
The available alternatives of zero values, or pointers each have significant drawbacks.
Additional context
This is the full implementation of our generic optional type
optional.Value
, but the configuration options allow anyone else to sub their own in. Happen to open a Pull Request with the changes if you like the idea.The text was updated successfully, but these errors were encountered: