differential-datalog icon indicating copy to clipboard operation
differential-datalog copied to clipboard

Allow pattern matches in `for`, `FlatMap`, closures

Open ryzhyk opened this issue 4 years ago • 3 comments

We currently don't allow any of the following:

for ((k,v) in map)
(var x, var y) = FlatMap(expr)
|(x,y)| x+y

ryzhyk avatar Oct 22 '20 20:10 ryzhyk

Also if ((k,v) = z), which evaluates to true only if the pattern matching succeeds.

mihaibudiu avatar Jan 12 '21 18:01 mihaibudiu

I would prefer a rust-like if let (k, v) = z {} so it's clear that pattern matching is happening

Kixiron avatar Jan 12 '21 20:01 Kixiron

I am with @Kixiron on this one. if ((k,v) = z) is very unorthodox. I haven't seen this in any other language.

if let (k, v) = z {} on the other hand is just syntactic sugar around match.

ryzhyk avatar Jan 12 '21 21:01 ryzhyk