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
I've been thinking about treating keywords as enum values, e.g. enum Foo { Bar, Baz } <=> :Bar and :Baz, which would be nicely derive-able.
However, a Keyword value requires a NameStore to find its string value, which means you can't IntoValue or FromValue it.
I can think of a couple of ways around this:
Add a Scope argument to conversion functions, so they can do a lookup if necessary
Change keywords to Keyword(String) in the Value enum, or add Symbol(String), to make self-representing keywords or symbols, as with similar parenthesized languages
Make string<->keyword conversion functions (which might be useful anyway!) that can be added in automatically by interop macros.
I'd be happy to dive in and make a PR, but each of these has trade-offs! Also, is there a better way I've not thought of?
[EDIT] Or a new EnumValue trait similar to StructValue, but I'm not sure what kind of machinery would need to go in there.
The text was updated successfully, but these errors were encountered:
What you're describing sounds like the value_encode module, which is enabled when you build using the serde feature. Any type implementing serde's Serialize/Deserialize traits can be converted to/from a Ketos value.
Hey, that's neat!
I did have a more terse solution in mind, but on meditation I realized I'd have to write some glue in Ketos anyway, meaning I can just do the conversion myself. Plus, what I was describing would only really be applicable to a small subset of enum types (those without arguments), so it's not all that useful anyway.
Thanks for pointing me to that though - I can definitely use it, and sorry for the noise :)
I've been thinking about treating keywords as enum values, e.g.
enum Foo { Bar, Baz }
<=>:Bar
and:Baz
, which would be nicely derive-able.However, a
Keyword
value requires aNameStore
to find its string value, which means you can'tIntoValue
orFromValue
it.I can think of a couple of ways around this:
Scope
argument to conversion functions, so they can do a lookup if necessaryKeyword(String)
in the Value enum, or addSymbol(String)
, to make self-representing keywords or symbols, as with similar parenthesized languagesI'd be happy to dive in and make a PR, but each of these has trade-offs! Also, is there a better way I've not thought of?
[EDIT] Or a new
EnumValue
trait similar toStructValue
, but I'm not sure what kind of machinery would need to go in there.The text was updated successfully, but these errors were encountered: