clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
jimmy 2019-05-10T00:47:03.123Z

Knowing nothing about this, it seems like making transients iterable would make it possible without changes to RT. But not sure if that would be a good idea or not.

ghadi 2019-05-10T00:53:09.124Z

expanding the scope of what transients are capable of is generally a bad direction

ghadi 2019-05-10T00:55:07.125700Z

if you're passing transients to code that isn't aware of them, that's almost certainly a design error

ghadi 2019-05-10T00:57:58.127300Z

things you can do to various transients: update them (conj! / assoc! / pop! / disj! ) graduate them (persistent!) get (get / lookup) count them

seancorfield 2019-05-10T00:58:11.127800Z

Yeah, my understanding of transient/persistent is that the scope has always been intended to be very minimal

seancorfield 2019-05-10T00:58:52.128800Z

I was disappointed the other day that I couldn't update one 🙂

ghadi 2019-05-10T00:59:40.129600Z

same deal as with empty? -- you can update them with your own function

ghadi 2019-05-10T01:00:05.130200Z

but ya can't pass them to generic code that isn't aware of transients

seancorfield 2019-05-10T01:00:37.131Z

Yeah, my first reaction was "Aww!" and then I was like, "No, that makes perfect sense..." and I just assoc!'d in an updated value 🙂

seancorfield 2019-05-10T01:02:15.132200Z

After nine years of using Clojure, I don't question core decisions anywhere near as much as I used to 🙂

2019-05-10T01:06:18.132600Z

update! should be easily writable though

seancorfield 2019-05-10T01:16:32.133700Z

17 lines of code with ! added in the appropriate places 🙂 But each of those functions add up. And I only needed a specific arity (and it's the first time I've wanted update! in all those years).

devn 2019-05-10T01:51:02.133900Z

@jimmy yes, i wrote that on the ticket

devn 2019-05-10T01:52:43.135400Z

the options seem to be implement iterable or cond in empty? to do the (zero? (count coll)) for TransientCollections. Mike fikes has proposed the latter on the CLJS side.

ghadi 2019-05-10T02:06:11.140500Z

this is a bad idea devin

ghadi 2019-05-10T02:06:30.141100Z

empty? == (not (seq )) transients aren't seqs

devn 2019-05-10T02:06:42.141500Z

Are Arrays?

ghadi 2019-05-10T02:06:50.141700Z

are arrays what?

devn 2019-05-10T02:07:19.142400Z

(seq (java.util.ArrayList. [1 2]))

ghadi 2019-05-10T02:07:49.143400Z

transients are designed to have a limited amount of operations to work on them

ghadi 2019-05-10T02:07:54.143700Z

seq isn't one of them

ghadi 2019-05-10T02:08:14.143900Z

user=> (seq (transient []))
Execution error (IllegalArgumentException) at user/eval143 (REPL:1).
Don't know how to create ISeq from: clojure.lang.PersistentVector$TransientVector

devn 2019-05-10T02:08:25.144200Z

I'm well aware

ghadi 2019-05-10T02:08:54.144700Z

(i think it's a bad idea to make empty? work on transients in clojurescript as well)

ghadi 2019-05-10T02:20:36.150Z

(I think this issue is distinct from the issue of contains? being broken on transients - https://dev.clojure.org/jira/browse/CLJ-700 , as find already works on transients, so why shouldn't contains?)

ghadi 2019-05-10T02:21:11.150500Z

empty? has a particular implementation, fwiw, and I don't see it changing

devn 2019-05-10T02:23:02.150900Z

Yes, this is a separate issue. That is also noted on the empty? ticket.

ghadi 2019-05-10T02:50:44.155800Z

I guess I mean it's different in nature: one is a busted impl, one is enlarging the contract of transient

devn 2019-05-10T02:58:59.159200Z

https://dev.clojure.org/jira/browse/CLJ-1872 ticket is here if you're interested in adding your opinion. The short list of operations supported on transients makes sense, sure. You can add and remove things, get a value at a position, check for the existence of a value or values across vec/set/map, count them. All those fun things. Truth of the matter is I don't necessarily disagree with you, but I found myself at the contains? issue while poking around in JIRA today, and then found my way over to this ticket. The ticket is currently listed as a defect with critical priority. It was triaged and vetted. Were it not for these things, I may not have spent any time looking at it.

dominicm 2019-05-10T06:01:32.160700Z

A bounded-count would be fine on lazy sequences

dominicm 2019-05-10T06:01:57.161300Z

Seems reasonable to me to check whether the transient you're dealing with is empty.

2019-05-10T10:23:46.161500Z

I forgot about bounded-count

2019-05-10T10:25:07.161800Z

it already works on transients too

devn 2019-05-10T20:50:44.163200Z

I'm not sure I follow. Transients are counted?, and so bounded-count simply calls count on the transient.

seancorfield 2019-05-10T21:39:50.164400Z

@devn I think that was just in response to the comment about not being able to define empty? in terms of count because of potentially infinite lazy sequences...?

seancorfield 2019-05-10T21:40:04.164700Z

(so it could be defined in terms of bounded-count)

devn 2019-05-10T22:27:12.165200Z

ah, I see.