dlang-community / drepl

A REPL for D
Boost Software License 1.0
78 stars 20 forks source link

Integrate dub #4

Open MartinNowak opened 10 years ago

MartinNowak commented 10 years ago

Allow to fetch and use dub packages.

MartinNowak commented 10 years ago

This should also work for the online REPL.

ShigekiKarita commented 6 years ago

I made something related to this https://github.com/ShigekiKarita/grain/blob/master/example/repl.d

MartinNowak commented 6 years ago

I'd think of dub integration as some form of :dub mir command that will fetch and compile mir as shared library that will be linked against in D module for that command. Afterwards modules from that package can be imported. So it'd would be an interactive addition of dub modules.

You're appproach looks interesting, but it has a flaw. It statically links packages into every subsequent D module, i.e. you'll end up with dozens of copies of the package. That will break the One Definition Rule. You really need to compile packages as shared libraries to avoid this. Atm. dub's support to compile packages as shared libs is still not fully there, e.g. dependencies need to be shared libs as well to avoid ODR issues.

ShigekiKarita commented 6 years ago

ODR

Thanks for pointing out. I have not thought about it. Maybe also compiling separate static library like tmp/_dubdeps.a only with DUB packages and tmp/_mods%s.so without DUB packages can avoid ODR?