Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.match by

(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.

8 Answers

0 votes
by

Comment made by: dnolen

(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.

0 votes
by

Comment made by: pron

Hi. Any plans on resolving this?

0 votes
by

Comment made by: dnolen

I have no specific timeline, it will definitely be after 0.2.0, only focusing on bugs at the moment.

0 votes
by

Comment made by: leonardoborges

Is it worth me picking this up?

I've implemented a very rudimentary version of this that I'm using here: https://github.com/leonardoborges/imminent#pattern-matching

Would love to see this extended and officially supported though. Thoughts?

0 votes
by

Comment made by: dnolen

Yes happy to see someone pick this up.

0 votes
by

Comment made by: leonardoborges

Excellent! Would you have any pointers/guidelines? If not, I'll just go from first principles using what's described in https://github.com/clojure/core.match/wiki/Advanced-usage#participating-in-pattern-matching

0 votes
by

Comment made by: dnolen

Yeah the primary issue is just figuring out a good syntax for it. Once that's in place I don't think getting it working will be so hard.

0 votes
by
Reference: https://clojure.atlassian.net/browse/MATCH-4 (reported by dnolen)
...