Specify and reify are more localized ways to get it done.

On Thu, Oct 2, 2014 at 2:27 PM, David Nolen <[email protected]> wrote:

> Not dirty, it's the very reason extend-type exists. That said you
> absolutely should not be doing something like this to FileList or
> HTMLCollection in library code - only application code.
>
> David
>
> On Thu, Oct 2, 2014 at 2:15 PM, Marcus Lewis <[email protected]> wrote:
> > Ok. Extend-type feels a little dirty, since it's relatively invisible
> (you can't tell by looking at code that it's dealing with FileLists or
> HTMLCollections, so you could be deceived into thinking this code will
> "just work" in other contexts, not knowing that it's depending on an
> extend-type somewhere else in the codebase). But I think I get where you're
> coming from.
> >
> > On Thursday, October 2, 2014 9:00:15 AM UTC-7, David Nolen wrote:
> >> You can solve this yourself with extend-type. We're not going to do any
> detection around  array likes in core.
> >>
> >> On Thursday, October 2, 2014, Marcus Lewis <[email protected]> wrote:
> >> => (doseq [file lastFileList] (.-name file))
> >>
> >> Error: [object FileList] is not ISeqable
> >>
> >>     at Error (native)
> >>
> >>     at cljs.core.seq (http://localhost:8080/app.js:3164:67)
> >>
> >>
> >>
> >> => (doseq [file (array-seq lastFileList)] (.log js/console (.-name
> file)))
> >>
> >>
> >>
> >> This works. It logs the filename. In case you're curious, this FileList
> is coming from drag-drop events)
> >>
> >>
> >>
> >> Here's the ClojureScript that I would hope would catch this:
> >>
> >>       (array? coll)
> >>
> >>       (when-not (zero? (alength coll))
> >>
> >>         (IndexedSeq. coll 0))
> >>
> >>
> >>
> >> The resulting js is:
> >>
> >>     if (a instanceof Array || "string" === typeof a) {
> >>
> >>         return 0 === a.length ? null : new cljs.core.IndexedSeq(a, 0);
> >>
> >>     }
> >>
> >>
> >>
> >> Is there any reason not to make other array-like types ISeqable? I'm
> sure there are better examples than FileList. For example, the same issue
> can be seen with HTMLCollection:
> >>
> >>
> >>
> >> => (seq (.getElementsByTagName js/document.body "div"))
> >>
> >> Error: [object HTMLCollection] is not ISeqable
> >>
> >>     at Error (native)
> >>
> >>     at cljs.core.seq (http://localhost:8080/app.js:3164:67)
> >>
> >>
> >>
> >> --
> >>
> >> Note that posts from new members are moderated - please be patient with
> your first post.
> >>
> >> ---
> >>
> >> You received this message because you are subscribed to the Google
> Groups "ClojureScript" group.
> >>
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> >>
> >> To post to this group, send email to [email protected].
> >>
> >> Visit this group at http://groups.google.com/group/clojurescript.
> >
> > --
> > Note that posts from new members are moderated - please be patient with
> your first post.
> > ---
> > You received this message because you are subscribed to the Google
> Groups "ClojureScript" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/clojurescript.
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to