Schmavery / reprocessing

ReasonML graphics library inspired by Processing
https://schmavery.github.io/reprocessing/
MIT License
682 stars 24 forks source link

Hotreloading doesn't work with Complex stdlib module #114

Open bsansouci opened 6 years ago

bsansouci commented 6 years ago

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

outkine commented 5 years ago

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'
jozanza commented 5 years ago

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

bsansouci commented 5 years ago

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 :)

jozanza commented 5 years ago

@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 😅

bsansouci commented 5 years ago

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.

outkine commented 5 years ago

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.

bsansouci commented 5 years ago

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.

jozanza commented 5 years ago

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