www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ipython/jupyter notebook - idea for making it a full REPL

At the moment, thanks to John Colvin's work, you can write D in 
an ipython/Jupyter notebook.  I find it a nicer work flow for 
playing around with things, since you can see results inline, and 
iterate rapidly.  In theory maybe no better than having your 
editor/IDE hooked up, but the difference between theory and 
practice is greater in practice than in theory...

It's early stage, so there are no line numbers, and hard to see 
which bit of code a compile error refers to.  But still quite 
useable.

You can hook up your own (or code.dlang.org) libraries via dub 
arguments passed in the notebook.  So same idea as python - your 
libraries do all the work and you write some light scripting in 
the notebook in an iterative way as you see the results evolve.

And of course you can call bash, lua, redis etc from within the 
notebook.

One thing that might be helpful is to turn it into a proper D 
REPL.

At the moment if you write:
%%pyd
writefln("hello world");

It won't go well.  You need the imports and a function wrapper.  
That doesn't matter in this case, but it would be nice to be able 
to write immediate code that retains state without rerunning from 
scratch.

so for example

%%pyd
 pdef auto getApple()
{
   bars=priceBars("NASDAQ/AAPL");
}
you can in python do:
bars=getApple()

and then if the auto conversion works, or you have written 
something bars will
be a python object that you can operate on - display, chart etc.

but it would be nice to be able to write pure D code in REPL mode 
within the notebook.

so:
%%pyd
auto bars=priceBars("NASDAQ/AAPL");

and then in next cell
   %%pyd
   bars=bars[$-100..$]l;
   bars.chartOHLC;

so you would have a REPL as we do already, but with all the 
features of Jupyter.  I had an idea about how to do this, but I 
am sure it could be improved.  More here:

https://github.com/DlangScience/PydMagic/issues/21
Aug 07 2015