core.match

Optimized pattern matching on deftype/record, POJOs

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major 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.

Activity

Hide
David Nolen added a comment -

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

Show
David Nolen added a comment - I have no specific timeline, it will definitely be after 0.2.0, only focusing on bugs at the moment.
Hide
Ron Pressler added a comment -

Hi. Any plans on resolving this?

Show
Ron Pressler added a comment - Hi. Any plans on resolving this?
Hide
David Nolen added a comment - - edited
(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.

Show
David Nolen added a comment - - edited
(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.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: