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.
Alex Miller made changes -
Field Original Value New Value
Labels function patch transient collections transient
Alex Miller made changes -
Approval Triaged [ 10120 ]
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!
Devin Walters made changes -
Attachment 0001-Add-transient-predicate.patch [ 12883 ]
Devin Walters made changes -
Attachment 0001-Add-transient-predicate.patch [ 12881 ]
Devin Walters made changes -
Labels collections transient collections patch test transient
Alex Miller made changes -
Labels collections patch test transient collections transient
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.
Alex Miller made changes -
Patch Code [ 10001 ] Code and Test [ 10002 ]
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.
Devin Walters made changes -
Attachment 0002-Add-transient-predicate.patch [ 12892 ]

People

Vote (0)
Watch (4)

Dates

  • Created:
    Updated: