Clojurescript keywords starting with numbers and read-string
Hi, I have a problem with read-string in Clojurescript. Reading keywords starting with a number will fail: (cljs.reader/read-string :123) (cljs.reader/read-string :1abc) Both will return following error: Uncaught TypeError: Cannot read property '0' of null I think this is a bug. Any suggestions? Cheers, Jens -- 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
ClojureScript keywords
Hi, When I compile the following to JavaScript, I expected it to output foo in the console log: (.log js/console (name :foo)) However, it outputs ï· 'foo. Is that right? Regards, Stuart -- 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: ClojureScript keywords
Please excuse the self-reply; Looking at the compiled version of (keyword?), I can see a line that appears to compare the first character of the keyword string against a multi-character string constant: cljs.core.keyword_QMARK_ = (function keyword_QMARK_(x){ var and__3574__auto2211 = goog.isString.call(null,x); if(cljs.core.truth_(and__3574__auto2211)) {*return cljs.core._EQ_.call(null,x.charAt(0),ï· );* } else {return and__3574__auto2211; } }); Stepping into cljs.core._EQ_ in the debugger shows that the first argument is one character long, but the second is 3 characters long. Is this just some encoding issue in my setup? I'm on Mac OS X 10.5, and I got the same result in FF 6 and Chrome 13. On 2 September 2011 17:41, Stuart Campbell stuart.william.campb...@gmail.com wrote: Hi, When I compile the following to JavaScript, I expected it to output foo in the console log: (.log js/console (name :foo)) However, it outputs ï· 'foo. Is that right? Regards, Stuart -- 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 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: ClojureScript keywords
Clojurescript represents symbols and keywords as strings with a one character unicode prefix (as an implementation detail). But, by default it outputs javascript as utf-8, and unless you are serving javascript from a server and have setup the headers accordingly, this will be misinterpreted by the browser as 3x iso-8859-1 characters. However, if you run with the advanced compiler, it will escape everything to ascii so you won't get these encoding issues. There is a jira issue to make the unoptimised path do the same encoding as the advanced compiler, but this isn't fixed yet. -- Dave On 2 Sep 2011 09:28, Stuart Campbell stuart.william.campb...@gmail.com wrote: Please excuse the self-reply; Looking at the compiled version of (keyword?), I can see a line that appears to compare the first character of the keyword string against a multi-character string constant: cljs.core.keyword_QMARK_ = (function keyword_QMARK_(x){ var and__3574__auto2211 = goog.isString.call(null,x); if(cljs.core.truth_(and__3574__auto2211)) {*return cljs.core._EQ_.call(null,x.charAt(0),ï· );* } else {return and__3574__auto2211; } }); Stepping into cljs.core._EQ_ in the debugger shows that the first argument is one character long, but the second is 3 characters long. Is this just some encoding issue in my setup? I'm on Mac OS X 10.5, and I got the same result in FF 6 and Chrome 13. On 2 September 2011 17:41, Stuart Campbell stuart.william.campb...@gmail.com wrote: Hi, When I compile the following to JavaScript, I expected it to output foo in the console log: (.log js/console (name :foo)) However, it outputs ï· 'foo. Is that right? Regards, Stuart -- 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 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 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: ClojureScript keywords
Thanks David. I added meta charset=UTF-8 to my HTML document (this is just a static test project) and it fixed the problem. Regards, Stuart On 2 September 2011 18:36, David Powell d...@djpowell.net wrote: Clojurescript represents symbols and keywords as strings with a one character unicode prefix (as an implementation detail). But, by default it outputs javascript as utf-8, and unless you are serving javascript from a server and have setup the headers accordingly, this will be misinterpreted by the browser as 3x iso-8859-1 characters. However, if you run with the advanced compiler, it will escape everything to ascii so you won't get these encoding issues. There is a jira issue to make the unoptimised path do the same encoding as the advanced compiler, but this isn't fixed yet. -- Dave On 2 Sep 2011 09:28, Stuart Campbell stuart.william.campb...@gmail.com wrote: Please excuse the self-reply; Looking at the compiled version of (keyword?), I can see a line that appears to compare the first character of the keyword string against a multi-character string constant: cljs.core.keyword_QMARK_ = (function keyword_QMARK_(x){ var and__3574__auto2211 = goog.isString.call(null,x); if(cljs.core.truth_(and__3574__auto2211)) {*return cljs.core._EQ_.call(null,x.charAt(0),ï· );* } else {return and__3574__auto2211; } }); Stepping into cljs.core._EQ_ in the debugger shows that the first argument is one character long, but the second is 3 characters long. Is this just some encoding issue in my setup? I'm on Mac OS X 10.5, and I got the same result in FF 6 and Chrome 13. On 2 September 2011 17:41, Stuart Campbell stuart.william.campb...@gmail.com wrote: Hi, When I compile the following to JavaScript, I expected it to output foo in the console log: (.log js/console (name :foo)) However, it outputs ï· 'foo. Is that right? Regards, Stuart -- 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 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 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 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