Clojurians
#lumo
<
2017-05-08
>

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

moxaj15:05:45

this might not be lumo-specific, but I tried using cljs.js/eval (as described here: http://blog.fikesfarm.com/posts/2016-01-22-clojurescript-eval.html), and while it evaluates my var correctly, it also warns about no such namespace and use of undeclared var. Furthermore, I get errors if I pass a bare symbol into eval instead of a fully qualified one

anmonteiro16:05:34

@moxaj do you mean the specific examples in that blog post?

moxaj16:05:13

@anmonteiro yep

anmonteiro16:05:35

@moxaj I’m busy now, but can you open an issue that I can investigate later?

moxaj16:05:59

as far as I can tell, planck.repl/eval is a thin wrapper around cljs.js/eval

moxaj16:05:14

which is what I used

anmonteiro16:05:23

not really, IIRC

anmonteiro16:05:01

and we may have to do the same in Lumo

moxaj16:05:10

oh, i'm aware of those, but my examples make no use of those

moxaj16:05:39

or maybe they do?

anmonteiro16:05:49

IDK, can you show me some examples of what you’re trying to do?

moxaj16:05:16

simply (eval '(+ a foo.core/b))

anmonteiro16:05:27

but Lumo has no support for eval

anmonteiro16:05:02

^ it’s planned, but hasn’t landed yet

moxaj16:05:12

I mean, I took the eval implementation from planck

moxaj16:05:18

does it need any more special care?

anmonteiro16:05:01

I don’t know. Maybe you could even put together a PR I can look at, since you’ve done the work?

anmonteiro16:05:03

:slightly_smiling_face:

moxaj16:05:54

i'll try! :slightly_smiling_face:

mfikes17:05:39

@moxaj Did you make your eval implementation consult the Lumo compiler state?

moxaj17:05:55

@mfikes nope

mfikes17:05:44

Based on “undeclared var” warnings, my only hunch is that this needs to be hooked in, as in on this line https://github.com/mfikes/planck/blob/master/planck-cljs/src/planck/repl.cljs#L1743

mfikes17:05:11

The st var is important

anmonteiro17:05:46

I thought that was implicit

anmonteiro17:05:04

clearly I shouldn’t make any assumptions

moxaj17:05:19

@mfikes but why does it work though with an empty compiler state?

moxaj17:05:41

(apart from the warnings)

mfikes17:05:05

Something like this probably works: (eval '(+ 1 2))

moxaj17:05:22

(eval '(+ 1 foo.core/b)) also works, despite the warnings

mfikes17:05:36

Oh, right.

mfikes17:05:09

That’s because it happens to turn in to JavaScript that references things that exist. Even though the analyzer isn’t happy, at runtime things are OK.

mfikes17:05:03

The analyzer is what is emitting the warnings. It is effectively checking that things being used are defined.

mfikes17:05:41

Another example of that is at http://blog.fikesfarm.com/posts/2015-06-10-analyze-path-ftw.html where foo.bar/square is used even without analysis info

moxaj17:05:03

@mfikes I see. Originally, I wanted to see if I could eval stuff at compile time, in both clojure, jvm clojurescript and self hosted. So unless I have access to some compiler state (which I don't), I have to live with the warnings?

anmonteiro17:05:52

@moxaj you can use lumo.repl/st

mfikes19:05:50

@moxaj FWIW on Planck's high level structure: planck.repl/eval uses planck.repl/st and is reused to implement other things (like resolve and intern), but it is primarily exposed via the publicly-facing planck.core/eval

mfikes19:05:28

The only corner case that I believe hasn't yet been satisfactorily resolved is https://github.com/mfikes/planck/issues/288