Details
-
Type:
Enhancement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
(match [x]
[({:a 0 :b 1} :type Foo)] :a0
...)
:a and :b would be converted to field access, i.e. (.a x)
As with primitive array matching, we should do an instance check followed by hinted field access.
We should consider adopting the deftype/record syntax.
(match [x] [^Foo {.-bar 5 .-baz 7}] :a0 [^Foo {.-bar _ .-woz 8}] :a1 :else :a2)Given the recent ClojureScript property access discussions this seems like an acceptable syntax for high-performance property access.
Maybe:
(match [^Foo x] [{.-bar 5 .-baz 7}] :a0 [{.-bar _ .-woz 8}] :a1 :else :a2)But probably not since then we should probably throw if someone tries to declare a different type in the row.
(match [x] [^Foo {.-bar 5 .-baz 7}] :a0 [^Foo {.-bar _ .-woz 8}] :a1 :else :a2)(match [^Foo x] [{.-bar 5 .-baz 7}] :a0 [{.-bar _ .-woz 8}] :a1 :else :a2)