foxfriends / lumber

Embeddable logic scripting language
5 stars 1 forks source link

Options #23

Closed foxfriends closed 3 years ago

foxfriends commented 3 years ago

Option<T> does not serialize the same way as other enums. Attempting to use such an option from Lumber is proving to be confusing.

There are two options here (no pun intended):

  1. Serialize options like other enums ('Option'('Some'(T)) and 'Option'('None'))
  2. Use the idea from #12 (where ?T and !T are patterns that match on the current bound-ness of a variable):
    • Let None in Rust mean "unbound" in Lumber (serializing to _).
    • Let Some(T) in Rust mean "bound" in Lumber (serializing to T).
    • When deserializing, deserialize an unbound variable (bound to _) to None and a variable bound to T to Some(T).
    • Serialize () to _, and deserialize to () always succeeds. (alternatively deserialize to () only succeeds if the value remains unbound?).