I recently hit exactly this question in a ClojureScript app I’m writing. It 
just so happens that Javascript provides a .indexOf method which is, as near as 
dammit, the same as the one provided by Java. So in this instance, portability 
isn’t an issue.

But having said that, I would still prefer to see this supported natively in 
Clojure, even if it’s just a wrapper around the interop. Using interop to do 
things that are as generic as simple string manipulation just feels messy.

--
paul.butcher->msgCount++

Silverstone, Brands Hatch, Donington Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
Skype: paulrabutcher

Author of Seven Concurrency Models in Seven Weeks: When Threads Unravel
http://pragprog.com/book/pb7con

On 19 July 2014 at 16:49:33, Andy Fingerhut (andy.finger...@gmail.com) wrote:

I would have to defer that question to someone who makes decisions regarding 
what goes into Clojure/ClojureScript, and what does not.

Of course, anyone else is free to create libraries that try to make portability 
between those two platforms easier.  Perhaps someone has already taken a go at 
creating such a thing?  I haven't used ClojureScript myself yet, so haven't 
looked for anything in that area.

Andy


On Sat, Jul 19, 2014 at 8:23 AM, Bruce Durling <b...@otfrom.com> wrote:
Andy,

How much of this reasoning do you think changes when we starting
thinking about being hosted on multiple platforms (I'm thinking
specifically clojure/clojurescript and cljx)?

cheers,
Bruce

On Sat, Jul 19, 2014 at 4:17 PM, Andy Fingerhut
<andy.finger...@gmail.com> wrote:
> Pierre:
>
> I maintain the cheatsheet, and I put .indexOf and .lastIndexOf on there
> since they are probably the most common thing I saw asked about that is in
> the Java API but not the Clojure API, for strings.  There are also links to
> whole Java classes and their entire API, e.g. for file I/O, for which there
> is no Clojure equivalent, since file I/O is a common need.  Clojure is meant
> to be a hosted language, not hiding its host platform, but making it easily
> callable.
>
> If there are entire Java classes that meet very common needs that aren't
> mentioned on the cheatsheet, I would consider adding links to their
> documentation pages.  I don't want to fill up the cheatsheet with many
> individual Java methods, though.
>
> As for why there are not Clojure equivalents of particular Java API methods,
> I think the reasoning might be similar (it has likely been discussed
> publicly, but I don't have a link handy) -- don't create a large number of
> Clojure functions that do nothing more than what the equivalent Java APIs
> do.
>
> Andy
>
>
> On Sat, Jul 19, 2014 at 3:58 AM, Pierre Masci <mas...@gmail.com> wrote:
>>
>> Hi all, just nit picking about Clojure's String API.
>>
>> I've been comparing it with Java's, and I noticed that (not surprisingly)
>> they are very similar.
>> There are just 2-3 functions that exist in Java but don't have an
>> equivalent in Clojure. I was wondering if they could be worth adding to
>> clojure.string :
>>
>> (.indexOf s "c")   and   (.lastIndexOf "c")
>>
>> (.startsWith s "danc")   and   (.endsWith s "ing")
>>
>> (.charAt s 5)
>>     same as (get s 5) but expresses a clearer intent. It's less general
>> than (get) though as it only applies to Strings, so that might be
>> unnecessary sugar.
>>
>>
>>
>>
>> .indexOf and .lastIndexOf are indicated in the Clojure Cheatsheet, maybe
>> .startsWith and .endsWith also deserve to be mentioned there?
>>
>> I've been wondering why some functions have been ported, like (lower-case)
>> for (.toLowerCase), but not the ones mentioned above.
>>
>> I told you it was nit picking (^c^) Clojure's API is awesome as it is.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
@otfrom | CTO & co-founder @MastodonC | mastodonc.com
See recent coverage of us in the Economist http://econ.st/WeTd2i and
the Financial Times http://on.ft.com/T154BA

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to