Clojure

Add transient? predicate

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.6
  • Fix Version/s: None
  • Component/s: None
  • Environment:
    N/A
  • Patch:
    Code and Test
  • Approval:
    Triaged

Description

I've encountered situations where I wanted to check whether something was transient in order to know whether I should call assoc! or assoc, conj! or conj, etc.

This patch adds `transient?` as a predicate fn.

Activity

Hide
Alex Miller added a comment -

Patch needs a docstring and a test.

Show
Alex Miller added a comment - Patch needs a docstring and a test.
Hide
Devin Walters added a comment - - edited

Alex: I figured that would be the case! Sorry about that. I've updated the patch. It now includes a docstring and has tests of `transient?` for #{}, [], and {}.

Thanks!

Show
Devin Walters added a comment - - edited Alex: I figured that would be the case! Sorry about that. I've updated the patch. It now includes a docstring and has tests of `transient?` for #{}, [], and {}. Thanks!
Hide
Alex Miller added a comment -

Thanks - please don't use the labels "patch" or "test" - those are covered by the Patch field.

Show
Alex Miller added a comment - Thanks - please don't use the labels "patch" or "test" - those are covered by the Patch field.
Hide
Devin Walters added a comment -

Ah, sorry for the mixup Alex. I assumed you removed "patch" as a label the first time around to flag this ticket as still needing a vetted patch. My mistake.

Show
Devin Walters added a comment - Ah, sorry for the mixup Alex. I assumed you removed "patch" as a label the first time around to flag this ticket as still needing a vetted patch. My mistake.
Hide
Andy Fingerhut added a comment -

Patch 0001-Add-transient-predicate.patch dated Mar 17, 2014 applies cleanly to latest Clojure master, but fails a test because the new function transient? has no :added metadata. See most other Clojure functions in clojure.core for examples.

It also generates a new warning while running tests:

WARNING: transient? already refers to: #'clojure.core/transient? in namespace: clojure.test-clojure.data-structures, being replaced by: #'clojure.test-clojure.data-structures/transient?

There is an older (but equivalent) definition of transient? in test file data_structures.clj that should be removed when adding it to clojure.core

Show
Andy Fingerhut added a comment - Patch 0001-Add-transient-predicate.patch dated Mar 17, 2014 applies cleanly to latest Clojure master, but fails a test because the new function transient? has no :added metadata. See most other Clojure functions in clojure.core for examples. It also generates a new warning while running tests: WARNING: transient? already refers to: #'clojure.core/transient? in namespace: clojure.test-clojure.data-structures, being replaced by: #'clojure.test-clojure.data-structures/transient? There is an older (but equivalent) definition of transient? in test file data_structures.clj that should be removed when adding it to clojure.core
Hide
Devin Walters added a comment - - edited

@Andy, the reason I did not add :added metadata is because I do not know if/when this patch will be accepted, and as a result, I don't really know if it will sneak into 1.6.X or 1.7. For now, I've put it in as 1.7. If it's in the running to be added sooner than that, let me know and I'll adjust it.

RE: The warning. Good catch. I've submitted a new patch which removes the private version of transient? from data_structures.clj. All tests pass.

Edit to Add: The latest patch as of this comment is now 0002-Add-transient-predicate.patch.

Show
Devin Walters added a comment - - edited @Andy, the reason I did not add :added metadata is because I do not know if/when this patch will be accepted, and as a result, I don't really know if it will sneak into 1.6.X or 1.7. For now, I've put it in as 1.7. If it's in the running to be added sooner than that, let me know and I'll adjust it. RE: The warning. Good catch. I've submitted a new patch which removes the private version of transient? from data_structures.clj. All tests pass. Edit to Add: The latest patch as of this comment is now 0002-Add-transient-predicate.patch.
Hide
Andy Fingerhut added a comment -

Patch 0002-Add-transient-predicate.patch dated Mar 22 2014 no longer applies cleanly to latest Clojure master due to some changes committed earlier today. I haven't checked whether this patch is straightforward to update.

Show
Andy Fingerhut added a comment - Patch 0002-Add-transient-predicate.patch dated Mar 22 2014 no longer applies cleanly to latest Clojure master due to some changes committed earlier today. I haven't checked whether this patch is straightforward to update.
Hide
Devin Walters added a comment -

I've updated the patch to 0003-Add-transient-predicate.patch. This patch applies cleanly to the latest version of master.

Show
Devin Walters added a comment - I've updated the patch to 0003-Add-transient-predicate.patch. This patch applies cleanly to the latest version of master.
Hide
Andy Fingerhut added a comment -

Patch 0003-Add-transient-predicate.patch dated Aug 6 2013 no longer applied cleanly to latest master after some commits were made to Clojure on Aug 29, 2014. It did apply cleanly before that day.

I have not checked how easy or difficult it might be to update this patch.

Show
Andy Fingerhut added a comment - Patch 0003-Add-transient-predicate.patch dated Aug 6 2013 no longer applied cleanly to latest master after some commits were made to Clojure on Aug 29, 2014. It did apply cleanly before that day. I have not checked how easy or difficult it might be to update this patch.

People

Vote (0)
Watch (4)

Dates

  • Created:
    Updated: