3 ms·
I think the best solution to this is when the language's syntax supports ORing cases together like this: let analyze_control_flow stmt = match stmt
by jasperry 6y ago
I think the best solution to this is when the language's syntax supports ORing cases together like this:
let analyze_control_flow stmt =
match stmt with
| If _ true_branch false_branch -> ...
| While _ body -> ..
| Assign _ _ | ExprStatement _ | Return -> ...
So you still get to avoid repeating code, but all the variants are included visibly and the compiler can verify it.