Clojure

A record? predicate would complement defrecord

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: Backlog
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

To improve Midje checkers/assertions, it'd be useful if we could ask an object if it were a-maplike-object-due-to-defrecord, rather than just ask it #'map?

Activity

Hide
Alex Miller added a comment - - edited

I have also run into the need to do this when implementing multimethods where records were treated in a specific way (for printing for example).

We wrapped defmacro to install a multimethod implementation of a record? function at record definition time but that's not a generic solution.

I imagine it would be easy for defrecord to construct a class that implements a marker IRecord interface that is checked by a record? predicate.

Show
Alex Miller added a comment - - edited I have also run into the need to do this when implementing multimethods where records were treated in a specific way (for printing for example). We wrapped defmacro to install a multimethod implementation of a record? function at record definition time but that's not a generic solution. I imagine it would be easy for defrecord to construct a class that implements a marker IRecord interface that is checked by a record? predicate.
Hide
Alex Miller added a comment -

In searching I noticed there is already a CLJ-394 which contains this (plus request for a marker on deftype).

Show
Alex Miller added a comment - In searching I noticed there is already a CLJ-394 which contains this (plus request for a marker on deftype).

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: