reprocessing icon indicating copy to clipboard operation
reprocessing copied to clipboard

Hotreloading doesn't work with Complex stdlib module

Open bsansouci opened this issue 7 years ago • 8 comments

Just writing this down so we remember to look into it one day. I have a project that uses the Complex module and the hotreloading is not liking it. When I run IndexHot I get a:

ERROR loading plugin: error while linking lib/bs/bytecode/lib.cma.
Reference to undefined global `Complex'

No idea why because Complex should be a module part of the stdlib... But maybe it has some dirty compiler hardcoded hacks to run faster and so you can't dynlink a module that uses Complex

bsansouci avatar Jul 31 '18 18:07 bsansouci

The same is true for CamlinternalOO. Complete error:

[1/1] Building lib.cma
bsb running with pid: 11680
Reloading hotloaded module
ERROR loading plugin: error while linking lib/bs/bytecode/lib.cma.
Reference to undefined global `CamlinternalOO'

outkine avatar Dec 01 '18 20:12 outkine

I also seem to be getting the Reference to undefined global `CamlinternalOO' error after adding some code that uses objects. 🤔

jozanza avatar Dec 15 '18 18:12 jozanza

Interesting! I had no idea that OCaml wold forgo the OO runtime stuff if no objects were used. I'd recommend not using objects for now while I look into a fix :)

bsansouci avatar Dec 17 '18 00:12 bsansouci

@bsansouci yeah I switched it up and found an alternative way to encapsulate things. I'm pretty new to reasonml, and using objects was probably not the best approach anyways 😅

jozanza avatar Dec 17 '18 01:12 jozanza

I wasn't gonna say it, but yeah, you'll get a lot of benefits from using records, functions and modules without the drawbacks of objects. Since you're new too, I think it'll be interesting for you to try these. They've substantially changed the way I code, leading to generally simpler and more robust code overall! But I don't necessarily want to disallow objects because they do have benefits.

bsansouci avatar Dec 17 '18 01:12 bsansouci

I think OCaml/Reason is a great learning tool because it gives you those two options. I'm planning on making two versions of my game - one with objects and one with modules - and then seeing which one works better.

outkine avatar Dec 17 '18 14:12 outkine

Amazing effort, I'd love to hear how it's going and can offer help for how to shape your game in the functional way. Ping me on discord.

bsansouci avatar Dec 17 '18 17:12 bsansouci

Oh what's the Discord server for this sort of convo?

jozanza avatar Dec 17 '18 17:12 jozanza