Why does cljs.core redefine String.prototype.apply?

2012-09-18 Thread Matt Campbell
I noticed that cljs.core redefines String.prototype.apply. Being new to 
Clojure, I don't understand what this redefinition does or what it is 
for. But I do know that redefining functions in the JS standard library, 
or defining new ones on standard objects, is something that should be 
done with great care, to avoid breaking other pieces of JavaScript 
running in the same context (e.g. on the same page). (And lest you think 
your JavaScript is sure to be the only JavaScript on your page, bear in 
mind that some browsers make web pages accessible to blind users by 
injecting their own JS into the page.)


I know there are always trade-offs. And perhaps this definition of 
String.prototype.apply is known not to conflict with any other 
JavaScript code. But I would appreciate an explanation of what purpose 
it serves.


Thanks,
Matt



smime.p7s
Description: S/MIME Cryptographic Signature


Why does cljs.core redefine String.prototype.apply?

2012-09-18 Thread Matt Campbell
 I noticed that cljs.core redefines String.prototype.apply. Being new to 
Clojure, I don't understand what this redefinition does or what it is for. 
But I do know that redefining functions in the JS standard library, or 
defining new ones on standard objects, is something that should be done 
with great care, to avoid breaking other pieces of JavaScript running in 
the same context (e.g. on the same page). (And lest you think your 
JavaScript is sure to be the only JavaScript on your page, bear in mind 
that some browsers make web pages accessible to blind users by injecting 
their own JS into the page.) 

I know there are always trade-offs. And perhaps this definition of 
String.prototype.apply is known not to conflict with any other JavaScript 
code. But I would appreciate an explanation of what purpose it serves. 

Thanks, 
Matt 

-- 
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

Re: Why does cljs.core redefine String.prototype.apply?

2012-09-18 Thread David Nolen
On Mon, Sep 17, 2012 at 11:26 AM, Matt Campbell mattcampb...@pobox.com wrote:
 I noticed that cljs.core redefines String.prototype.apply. Being new to
 Clojure, I don't understand what this redefinition does or what it is for.
 But I do know that redefining functions in the JS standard library, or
 defining new ones on standard objects, is something that should be done with
 great care, to avoid breaking other pieces of JavaScript running in the same
 context (e.g. on the same page). (And lest you think your JavaScript is sure
 to be the only JavaScript on your page, bear in mind that some browsers make
 web pages accessible to blind users by injecting their own JS into the
 page.)

 I know there are always trade-offs. And perhaps this definition of
 String.prototype.apply is known not to conflict with any other JavaScript
 code. But I would appreciate an explanation of what purpose it serves.

 Thanks,
 Matt

It's a yucky bit of code that needs to be removed. It's there to
support using keywords as functions - in ClojureScript keywords are
just JS Strings.

David

-- 
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


Re: Why does cljs.core redefine String.prototype.apply?

2012-09-18 Thread Matt Campbell

On 9/18/2012 8:06 AM, David Nolen wrote:

It's a yucky bit of code that needs to be removed. It's there to
support using keywords as functions - in ClojureScript keywords are
just JS Strings.


Is there another way to do the same thing, without a significant 
performance penalty?


Matt



smime.p7s
Description: S/MIME Cryptographic Signature


Re: Why does cljs.core redefine String.prototype.apply?

2012-09-18 Thread David Nolen
On Tue, Sep 18, 2012 at 9:27 AM, Matt Campbell mattcampb...@pobox.com wrote:
 On 9/18/2012 8:06 AM, David Nolen wrote:

 It's a yucky bit of code that needs to be removed. It's there to
 support using keywords as functions - in ClojureScript keywords are
 just JS Strings.


 Is there another way to do the same thing, without a significant performance
 penalty?

 Matt

Probably! A simple clean solution could probably deal with the issue
immediately. A more ambitious solution would address the performance
issues that currently exist around keywords as fns.

A patch most welcome.

David

-- 
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