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
"Match" was chosen purely due to Rust. "Switch" or "Case" would also be valid names for this feature.
I also feel that the : syntax might not be clear enough - a more traditional => might work better.
Modality inference might also be a challenge, as the compiler would need to know whether every possible subtype had been provided to determine whether the expression always returns a value.
The text was updated successfully, but these errors were encountered:
I've written an RFC for match statement, but it currently only allows comparisons with ==, not is as you suggested.
The RFC will probably evolve into proper pattern matching & deconstructing, but because this is very complicated on the implementation side, it surly won't make it into 3.0.
If we decide to implement RFC as is for 3.0, this would be workaround for your example:
property normalized_data := (
SELECT match true {
.data is learning::StringCollectionUnit -> array_join(.data[is learning::StringCollectionUnit].string_collection_value, ','),
.data is learning::NumberCollectionUnit -> array_join(<array<str>>.data[is learning::NumberCollectionUnit].number_collection_value, ','),
.data is learning::NumberUnit -> <str>.data[is learning::NumberUnit].number_value,
.data is learning::StringUnit -> .data[is learning::StringUnit].string_value,
}
)
... which is not much more readable than the original.
One user asked if there was a more concise way to write this query:
A
match
statement would allow the above query to be written as such:"Match" was chosen purely due to Rust. "Switch" or "Case" would also be valid names for this feature.
I also feel that the : syntax might not be clear enough - a more traditional => might work better.
Modality inference might also be a challenge, as the compiler would need to know whether every possible subtype had been provided to determine whether the expression always returns a value.
The text was updated successfully, but these errors were encountered: