"import" after aot compilation?
pvinis opened this issue ยท 4 comments
im using fennel for a project (specifically for a https://play.date game), and i am not sure what i need to write to have the output of the compilation be an import.
fennel:
; something with "CoreLibs/graphics"?
(playdate.graphics.drawRect 50 50 80 80)
(print "works")
lua:
import "CoreLibs/graphics" -- this one is missing, thats the one im trying to figure out how to have.
playdate.graphics.drawRect(50, 50, 80, 80)
return print("works")
any ideas?
From what I can tell here the problem is the playdate devs seem to have forked Lua and broken the module system. I can't really tell what import
does here; either it sets some values as globals, or it implicitly creates locals. Either one is real bad; it makes static analysis impossible, undermining the help that the compiler can give.
The weirdest part is that they didn't have to do this; require
is flexible enough to do this without forking the language. But I guess there's nothing you can do about that.
I think the best you can do is use the lua
special form to emit the import directly:
(lua "import \"CoreLibs/graphics\"")
It's included as a kind of escape hatch for things like this where Fennel can't emit the code you want because it's not part of Lua.
oOoOO interesting. I'll try that, thank you for the pointer!
This totally worked (lua "import \"CoreLibs/graphics\"")
.
Thank you so much. Closing.