_Comment made by: r0man_
The attached patch adds an additional clause to `pr-writer-impl` and
implements the printing of Symbol instances, in the same way as it is
done for other JavaScript objects. Here's an example of a printed
js/Symbol:
(.for js/Symbol "react.element")
;;=> #object[Symbol "react.element"]
@david: Regarding your point about shims, do you think the
implementation of `js-symbol-defined?`, which was used for the ES6
iterator support, is enough for this patch? I'm not too familiar with
JavaScript and not sure if this already addressed the "shim" issue.
Another thing I stumbled upon is, that my test currently generates a
compiler warning when using the default compiler options. The warning
is generated when compiling the following ClojureScript form:
(.for js/Symbol "react.element")
The following snippet shows the warning and the generated code from my
test:
WARNING - Keywords and reserved words are not allowed as unquoted
property names in older versions of JavaScript. If you are targeting
newer versions of JavaScript, set the appropriate language_in option.
try{var values__13328__auto__ = (function (){var x__6628__auto__ = cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.array_seq([Symbol.for("react.element")], 0));
I think this has nothing to do with this patch, but with the emitted
code not being legal Ecmascript 3, since "for" is a reserved word.
The warning goes away when changing the :language-in option to
something newer than Ecmascript 3, or doing something like this:
((gobj/get js/Symbol "for") "react.element")
So, the questions is: Should the ClojureScript compiler handle those
reserved words when they appear in a function call or property lookup?
If that's the case I would leave the warning in that patch, and open
another issue for this new problem.
What do you think?
Roman