www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - repl like interface with D app

reply Mike B Johnson <Mikey Ikes.com> writes:
I am developing a D app and I have a need to test things out. I 
do not want to have to recompile the app every time I want to 
test some functionality out.


Suppose I have an app with some functions like foo, bar, etc... 
in some module m.

I would like to be able to do basic stuff like

 writeln(m.foo());
or
 auto x = m.bar() + 3;
etc... This way I can write the functions, compile, then test them out without compiling. e.g.,
 m.FlipLightSwitch(34);
which turns on the 34th light in the house, then
 m.FlipLightSwitch(34);
which turns it off. This should take about 1-2 seconds to test RATHER than about 1m to do the compilation, running, etc. Having a history buffer would be nice too and even a debugger showing the basic state(nothing fancy). Anything like this out there. Lua has things like this that are very nice to do because they allow for quick testing and prototyping.
Jun 16
next sibling parent reply Seb <seb wilzba.ch> writes:
On Friday, 16 June 2017 at 07:57:46 UTC, Mike B Johnson wrote:
 I am developing a D app and I have a need to test things out. I 
 do not want to have to recompile the app every time I want to 
 test some functionality out.

 [...]
There is drepl, it's not fancy, but works for basic use cases... https://github.com/drepl/drepl
Jun 16
parent Mike B Johnson <Mikey Ikes.com> writes:
On Friday, 16 June 2017 at 18:13:33 UTC, Seb wrote:
 On Friday, 16 June 2017 at 07:57:46 UTC, Mike B Johnson wrote:
 I am developing a D app and I have a need to test things out. 
 I do not want to have to recompile the app every time I want 
 to test some functionality out.

 [...]
There is drepl, it's not fancy, but works for basic use cases... https://github.com/drepl/drepl
But that doesn't interface with ones own program? I'm not talking about a standalone repl but something what can use from their own program and then use that command line interface of it(or just send command through text) and interact with the original program: string foo() { writeln("foo"); } void main() { repl.init(); writeln(repl.exec("foo()")); writeln(repl.exec(readline())); repl.OpenInterface(); // <- A new command window is open that lets us run code from it, code that has access to this programs code. } Or whatever.
Jun 16
prev sibling parent reply Sameer Pradhan <pradhan cemantix.org> writes:
On Friday, 16 June 2017 at 07:57:46 UTC, Mike B Johnson wrote:
 I am developing a D app and I have a need to test things out. I 
 do not want to have to recompile the app every time I want to 
 test some functionality out.


 Suppose I have an app with some functions like foo, bar, etc... 
 in some module m.

 I would like to be able to do basic stuff like

 [...]
or
 [...]
etc... This way I can write the functions, compile, then test them out without compiling. e.g.,
 [...]
which turns on the 34th light in the house, then
 [...]
which turns it off. This should take about 1-2 seconds to test RATHER than about 1m to do the compilation, running, etc. Having a history buffer would be nice too and even a debugger showing the basic state(nothing fancy). Anything like this out there. Lua has things like this that are very nice to do because they allow for quick testing and prototyping.
Please check out: https://github.com/DlangScience/PydMagic/blob/master/README.md I haven't used it myself, but fits right in the Jupyter/IPython ecosystem. -- Sameer
Jun 16
parent Mike B Johnson <Mikey Ikes.com> writes:
On Friday, 16 June 2017 at 18:43:24 UTC, Sameer Pradhan wrote:
 On Friday, 16 June 2017 at 07:57:46 UTC, Mike B Johnson wrote:
 [...]
Please check out: https://github.com/DlangScience/PydMagic/blob/master/README.md I haven't used it myself, but fits right in the Jupyter/IPython ecosystem. -- Sameer
Thanks, not sure if this will work and I don't like python much, but I'll give a look at some point and see. Maybe it can be integrated back in to a D program and then work out well: D->python->D.
Jun 16