That's definitively a workaround that would work for most common cases. Googling around I found the definition of a JS identifier (ES 5.1) is not exactly trivial: http://mathiasbynens.be/notes/javascript-identifiers . I can't even see what part of the definition prevents dash in names. The author of this article also states a complete regex would be 11,236 characters long..
I figured the best option would be to rely on the browser itself by checking the function would be accessible after installing it. Julien 2014-01-29 David Nolen <[email protected]> > This seems like a non-problem to me. Valid JavaScript identifiers are > easily identifiable with a regex no? > > > On Wed, Jan 29, 2014 at 9:23 PM, Julien Eluard <[email protected]>wrote: > >> Hi Adrian, >> >> essentially I want to install some function on a JS object from >> ClojureScript, and make sure it can be called from JS. >> >> My issue is that I don't know how to enforce a valid function name from >> the ClojureScript side. Because the function name is only known at runtime >> I can only use aget/aset which in turns rely on the JS bracket operator. >> The bracket operator doesn't appear to restrict property names while >> function name have some restrictions. >> >> For instance I could install 'invalid-name' from ClojureScript but >> obj.invalid-name() would fail from JS side (the trick being that >> obj['invalid-name'] would reference the function). >> >> Looking at the code from goog.reflect I can see it relies on the bracket >> operator so I don't think it can help. >> >> Julien >> >> >> 2014-01-29 <[email protected]> >> >> goog.reflect ( >>> http://docs.closure-library.googlecode.com/git/namespace_goog_reflect.html) >>> might be what you're looking for - but I'm not sure I understand your >>> problem. >>> >>> -- >>> 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.
