Nested (or) in (case) patterns

This commit is contained in:
2021-01-04 09:02:06 -07:00
parent 10e514e1e0
commit a2555dc0c1
4 changed files with 19 additions and 10 deletions

View File

@@ -341,16 +341,17 @@
(case 5
((when false (or 5 6)) (Assert.fail))
(otherwise (Assert.pass)))
// TODO in Haxe,
// In Haxe,
// `switch (Some(true)) { case Some(true | false): "a"; default: "b"; }`
// returns "a", so this should also be valid:
/*(case (Some true)
// returns "a", so nested use of `or` in case patterns should also be valid:
(case (Some true)
((Some (or true false))
(Assert.pass))
(otherwise (Assert.fail)))*/
// ^ Implement by overriding the `or` macro with an `or` special form to return variadically nested OpOr binop exps
// in KissState.forCaseParsing() instead of handling CallExp(Symbol(or)) specially
)
(otherwise (Assert.fail)))
(case (Some 5)
((Some (or 6 5 4))
(Assert.pass))
(otherwise (Assert.fail))))
(defun _testMaps []
(deflocal :Map<String,String> myMap [=>"hey" "you"