Fork me on GitHub
#clojurescript
<
2020-03-07
>
uneman07:03:48

when writing anonymous function, is there a way to emit this without additional assignment? (like no var this$ = this) The library I'm using (GPU.js) takes a JS function and transpiles it to a shader and it only takes the exact form of this.thread.x not this$.thread.x . so to speak, the JS AST works as a DSL in GPU.js so accessing properties should be verbatim sometimes..

thheller09:03:43

@namenu unfortunately no. this also doesn't sound like a good idea when using :advanced compilation since it might heavily modify what your code looks like

p-himik10:03:10

Couldn't you do it with js*?

thheller10:03:49

that still goes through advanced ...

uneman11:03:40

yes, I was wondering if there's a optimization safe way to do this. (it works ok with *js on dev)

p-himik11:03:59

You probably can write a regular JS file and add /** @nocompile */ at the very top of it, and use exports from CLJS in there.

uneman11:03:00

thanks! I should move all my kernel functions outside. 🙂

👍 4
thheller11:03:05

is there no way to pre-generate the shader from the JS? I mean it sounds like a terrible idea to me to do that at runtime?

uneman11:03:14

yes there is. but the purpose of GPU.js is abstracting out GLSL and direct use of gluing gl functions. https://github.com/gpujs/gpu.js/wiki/Quick-Concepts#simple-javascript for people like me who don't know the GLSL syntax but still want to use GPU for general purpose, it was kind of option I guess..?

thheller11:03:19

yes I get that. seems like a neat idea. I just don't get the part of doing it at runtime. that means it requires parsing JS at runtime, meaning you need to embed a JS parser/analyzer etc

thheller11:03:47

if you just do it beforehand you can still write plain JS but the final code only contains the already generated shader

thheller11:03:51

no JS parser etc required at runtime ... equals smaller file sizes, faster startup, etc

thheller11:03:46

but no clue what that library does so it may just be for technical reasons they don't do it

uneman12:03:46

I got your point. Then I found it also providing export/import of precompiled JSON, although have some steps to be done at runtime. thanks, now I have +1 way to get through this!

deplect16:03:30

goodday, any advice on how to proceed to integrate a facebook login on a clojurescript app?