mfikes answered this on the clojurescript slack channel

mfikes: You can get around this by, for example doing `(let [geval js/eval] 
> (geval "function abc(){}"))`
> @phronmophobic Yeah, I think you are right. Planck specifically doesn't do 
> that in order to fix, for example 
> https://github.com/mfikes/planck/issues/543 (see the bit at the very bottom 
> of that bug thread) (edited)


This is an odd behavior but it is due to how javascript behaves:

mfikes: By binding, `" the eval code is not being evaluated by a direct 
> call" 
> Then 1. a. applies here 
> http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.2
> In short, it is an ECMAScript 5 feature


On Tuesday, January 9, 2018 at 1:32:57 AM UTC+2, Sonny To wrote:
>
> clojuresript repl:
> stigmergy.loader> (js/eval "function abc(){}")
> nil
> stigmergy.loader> (js/abc)
> #object[ReferenceError ReferenceError: abc is not defined]                
>                                                                             
>                           
> nil
>
> javascript repl:
> eval("function abc(){}")
> 01:30:26.689 undefined
> 01:30:33.614 abc()
> 01:30:33.624 undefined
>
> why can't I define a functiion using js/eval but can using eval in 
> javascript?
>
> however this works:
>
> stigmergy.loader> (js/eval "foobar123 = function(){}")
> #object[foobar123]
> stigmergy.loader> (js/foobar123)
>
>

-- 
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 https://groups.google.com/group/clojurescript.

Reply via email to