differential-datalog
differential-datalog copied to clipboard
"if let" for DDlog
Rust has a syntactic construct "if let": https://doc.rust-lang.org/stable/rust-by-example/flow_control/if_let.html. This would be useful in DDlog as well. It would simplify commonly found patterns in OVN like this:
match (set_nth(acl.name, 0)) {
None -> (),
Some{name} -> vec_push(strs, "name=\"${name}\"")
};
to something more like this:
if (Some{var name} = set_nth(acl.name, 0)) {
vec_push(strs, "name=\"${name\"")
}
Currently the latter produces an error message like this:
ddlog: error: ../northd/ovn_northd.dl:1647:6-1647:21: Type constructor in the left-hand side of an assignment is only allowed for types with one constructor, but "std.Option" has multiple constructors
Agreed, this is often much more ergonomic than match. We should support the if-else form as well.