electric icon indicating copy to clipboard operation
electric copied to clipboard

Allow key function to be passed as metadata on `for`

Open eneroth opened this issue 1 year ago • 0 comments

  • for can be given a kf using metadata: ^{:by kf}. E.g., (e/for ^{:by :id} [v [{:id 0} {:id 1}]])
  • Warn when used without key function, but otherwise preserve previous behaviour for backwards compatibility.

The reason driving this suggestion is that for-by is problematic to use in Cursive, since there's no function in Clojure core that matches its signature, to which it could be resolved. Meanwhile, for can be extended to support a key function in a backwards compatible manner that doesn't interfere with its current functionality.

This PR includes logging a warning when for is used without specifying a key function, as it has been a long term wish expressed from the Electric team to wean the community off this behaviour.

eneroth avatar Apr 04 '24 14:04 eneroth