cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
2019-11-25T16:59:12.405Z

Shouldn’t cljs interop with iterable JS objects such as Set and Map via iterator protocol? So (first (js/Set. #js [1 2 3])) ;; 1 would be possible. Clojure allows (first (HashSet.))

lilactown 2019-11-25T17:48:16.405500Z

extending the seq abstraction to iterables would be pretty cool

alexmiller 2019-11-25T17:56:05.405800Z

iterator-seq

alexmiller 2019-11-25T17:56:16.406Z

oh, this is cljs, nvm! :)

2019-11-25T17:56:45.406200Z

there’s es6-iterator-seq indeed

2019-11-25T17:57:27.407500Z

but since Clojure already works with Java collections maybe cljs should be on par as well

souenzzo 2019-11-25T17:57:46.407900Z

There is some really wired lists like https://developer.mozilla.org/en-US/docs/Web/API/FileList that for me just works with (for [i (range (.-length x))] (aget x i))

2019-11-25T17:59:36.408800Z

@souenzzo For array-like collections in js one can use cljs.core/array-seq

2019-11-25T18:01:35.410100Z

iterables are different, though many array-like collection types in browser env might have been already upgraded to iterator protocol (Array for sure)

thheller 2019-11-25T20:25:57.411600Z

@roman01la the issue is that CLJS in theory generates ES3 code. that didn't have Map/Set, so if the protocols were extended onto those it wouldn't be ES3 anymore. not sure that it should either. could do it in a simple library.

lilactown 2019-11-25T20:33:59.412Z

Could do existence checks

thheller 2019-11-25T20:34:46.412700Z

that doesn't play well with :advanced

2019-11-25T21:46:16.413400Z

Maybe it's fine to include this code even if it's not used

dnolen 2019-11-25T21:56:46.414300Z

@roman01la there's no specific reason other than it hasn't been requested - I think it just means adding a new branch to seq

2019-11-26T16:37:58.417700Z

Submitted a patch https://clojure.atlassian.net/browse/CLJS-3199

dnolen 2019-11-25T21:57:30.415Z

we don't care about the specific types of course - just whether it's iterable - has "@@iterator" property or the actual iterator symbol

dnolen 2019-11-25T22:05:55.416500Z

@thheller re: var lifting support - I think that's definitely not something we intend to support in any direct kind of way.

thheller 2019-11-25T22:09:46.417Z

it would let reify generate better code but I guess that doesn't matter much

dnolen 2019-11-25T22:11:45.417400Z

yeah - not a pressing a concern