Clojurians
#cljs-dev
<
2015-12-30
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

bhauman18:12:24

I looked through the JIRA issues and I can't find anything about the problem of turning the new JavaScript Symbols to Strings

bhauman18:12:55

(str (js* "Symbol('hi')")) fails in Chrome because of a JS API inconsistency

bhauman18:12:37

this breaks prn and pprint

bhauman18:12:17

This is broken because the implementation of str relies on [x].join("") to implicitly call .toString which for some reason it doesn't for Symbol (in Chrome) at least

bhauman18:12:52

Symbol('works').toString() works

bhauman18:12:15

[Symbol('fails')].join("") fails

dnolen18:12:41

Need to see what spec says and what major browsed implement

dnolen18:12:50

Chrome isn't enough

bhauman18:12:21

Yeah checking others right now

bhauman18:12:56

Same behavior in latest version of Firefox

bhauman18:12:52

would have to upgrade my OS to upgrade Safari so not going there right now

bhauman18:12:43

Found this tidbit on MDN While you can call toString() on Symbols, you can't use string concatenation with them.

dnolen19:12:16

@bhauman: hrm OK would need more information - but this really sounds like a minor thing. What are you using Symbol for?

dnolen19:12:34

IMO they were horribly designed and fail to live up to the original goal

bhauman19:12:04

React uses it and if you try to print a React element, bam!

bhauman19:12:22

it is minor for sure, but it took me a while to find out why some of my devcards were failing

dnolen19:12:13

the issue should probably cross reference the other toString tickets

dnolen19:12:22

want to make sure we are not clobbering past decisions

dnolen19:12:39

or if we are that people are ready for it

bhauman19:12:12

yeah seems kinda hairy and Safari doesn't implement them yet.

bhauman19:12:21

I'm sure [x].join("") catches some odd cases where concatenation works but .toString() doesn't work. And now there is a case where .toString works but [x].join("") doesn't. Yippee

mfikes19:12:14

Dang. We already have a math multiply workaround in everyone's preamble for JavaScriptCore. Maybe time for yet another.