www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - early alpha of D REPL

reply Martin Nowak <code dawg.eu> writes:
Barely running but already fun and a little useful.

Example:

D> import std.algorithm, std.array, std.file;
=> std
D> auto name(T)(T t) {
  |     return t.name;
  | }
=> name
D> dirEntries(".", SpanMode.depth).map!name.join(", ")
=> ./drepl_sandbox
D>

https://github.com/MartinNowak/drepl
http://drepl.dawg.eu/
Feb 10 2014
next sibling parent reply "deadalnix" <deadalnix gmail.com> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
As I understand it, you are executing dmd in the background to repl. Simple and clever :D
Feb 10 2014
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 2/10/14, 9:01 PM, deadalnix wrote:
 On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
As I understand it, you are executing dmd in the background to repl. Simple and clever :D
But then how is it saving context? Andrie
Feb 10 2014
parent reply "Martin Nowak" <code dawg.eu> writes:
On Tuesday, 11 February 2014 at 05:37:45 UTC, Andrei Alexandrescu 
wrote:
 As I understand it, you are executing dmd in the background to 
 repl.
 Simple and clever :D
But then how is it saving context? Andrie
It's using shared libraries to do so. Each new deck/stmt/expr is compiled in a shared library. This library imports and links against all previous libraries to make the context available. I still need to implement a few rewrites, i.e. `auto var = val;` should become `typeof(val) var; shared static this() { var = val; }` too support runtime initialization.
Feb 11 2014
parent reply "extrawurst" <stephan extrawurst.org> writes:
On Tuesday, 11 February 2014 at 08:15:55 UTC, Martin Nowak wrote:
 On Tuesday, 11 February 2014 at 05:37:45 UTC, Andrei 
 Alexandrescu wrote:
 As I understand it, you are executing dmd in the background 
 to repl.
 Simple and clever :D
But then how is it saving context? Andrie
It's using shared libraries to do so. Each new deck/stmt/expr is compiled in a shared library. This library imports and links against all previous libraries to make the context available. I still need to implement a few rewrites, i.e. `auto var = val;` should become `typeof(val) var; shared static this() { var = val; }` too support runtime initialization.
Thats a nifty trick!
Feb 11 2014
parent reply "extrawurst" <stephan extrawurst.org> writes:
On Tuesday, 11 February 2014 at 08:49:56 UTC, extrawurst wrote:
 On Tuesday, 11 February 2014 at 08:15:55 UTC, Martin Nowak 
 wrote:
 On Tuesday, 11 February 2014 at 05:37:45 UTC, Andrei 
 Alexandrescu wrote:
 As I understand it, you are executing dmd in the background 
 to repl.
 Simple and clever :D
But then how is it saving context? Andrie
It's using shared libraries to do so. Each new deck/stmt/expr is compiled in a shared library. This library imports and links against all previous libraries to make the context available. I still need to implement a few rewrites, i.e. `auto var = val;` should become `typeof(val) var; shared static this() { var = val; }` too support runtime initialization.
Thats a nifty trick!
Did I just kill it ? After playing around the site is not responding anymore :( I am sorry....
Feb 11 2014
parent reply "Martin Nowak" <code dawg.eu> writes:
On Tuesday, 11 February 2014 at 08:51:50 UTC, extrawurst wrote:
 Did I just kill it ?
 After playing around the site is not responding anymore :( I am 
 sorry....
No problem :), it's the most important TODO right now to prevent this. https://github.com/MartinNowak/drepl/blob/master/examples/server.d#L34
Feb 11 2014
parent reply Martin Nowak <code dawg.eu> writes:
On 02/11/2014 04:24 PM, Martin Nowak wrote:

 No problem :), it's the most important TODO right now to prevent this.
 https://github.com/MartinNowak/drepl/blob/master/examples/server.d#L34
I wish SELinux was simpler, but it isn't. So instead of using a TCP socket, I quickfixed this issue by polling non-blocking process pipes https://github.com/MartinNowak/drepl/commit/1aef9acedb4ee4ee7cdcceda56796aba6d460cbe.
Feb 11 2014
parent reply =?UTF-8?B?U8O2bmtlIEx1ZHdpZw==?= <sludwig+dforum outerproduct.org> writes:
Am 12.02.2014 03:49, schrieb Martin Nowak:
 On 02/11/2014 04:24 PM, Martin Nowak wrote:

 No problem :), it's the most important TODO right now to prevent this.
 https://github.com/MartinNowak/drepl/blob/master/examples/server.d#L34
I wish SELinux was simpler, but it isn't. So instead of using a TCP socket, I quickfixed this issue by polling non-blocking process pipes https://github.com/MartinNowak/drepl/commit/1aef9acedb4ee4ee7cdcceda56796aba6d460cbe.
BTW, if you (can) use the latest vibe.d beta version, there is also the vibe.core.core.createFileDescriptorEvent function, which should work for waiting on the non-blocking pipes instead of busy-waiting with yield().
Feb 12 2014
parent Martin Nowak <code dawg.eu> writes:
On 02/12/2014 10:29 AM, Sönke Ludwig wrote:
 BTW, if you (can) use the latest vibe.d beta version, there is also the
 vibe.core.core.createFileDescriptorEvent function, which should work for
 waiting on the non-blocking pipes instead of busy-waiting with yield().
Nice, will try.
Feb 12 2014
prev sibling next sibling parent reply "thedeemon" <dlang thedeemon.com> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.
Have you seen Dabble? https://github.com/callumenator/dabble It works pretty well on my Win 7.
Feb 11 2014
next sibling parent reply "thedeemon" <dlang thedeemon.com> writes:
 Have you seen Dabble?
 https://github.com/callumenator/dabble
Just found out its author added Linux support. I was able to build an x86 version but it didn't work properly in a 64 bit system: it assumes dmd makes x86 binaries by default while it really makes 64-bit ones. And for 64 bits Dabble doesn't compile: as it often happens, it's too easy to forget that array.length is not always uint.
Feb 11 2014
parent reply "cal" <callumenator gmail.com> writes:
On Tuesday, 11 February 2014 at 11:33:53 UTC, thedeemon wrote:
 Have you seen Dabble?
 https://github.com/callumenator/dabble
Just found out its author added Linux support. I was able to build an x86 version but it didn't work properly in a 64 bit system: it assumes dmd makes x86 binaries by default while it really makes 64-bit ones. And for 64 bits Dabble doesn't compile: as it often happens, it's too easy to forget that array.length is not always uint.
I don't have a 64-bit tool-chain to play with, could submit those 64 bit build errors on github?
Feb 11 2014
parent "thedeemon" <dlang thedeemon.com> writes:
On Wednesday, 12 February 2014 at 04:43:00 UTC, cal wrote:
 On Tuesday, 11 February 2014 at 11:33:53 UTC, thedeemon wrote:
 Have you seen Dabble?
 https://github.com/callumenator/dabble
Just found out its author added Linux support. I was able to build an x86 version but it didn't work properly in a 64 bit system: it assumes dmd makes x86 binaries by default while it really makes 64-bit ones.
 I don't have a 64-bit tool-chain to play with, could submit 
 those 64 bit build errors on github?
I've just submitted a pull request for compiling dabble repl in 64 bits and created an issue on github with the linking problem arising when it tries to work. My diagnosis of the problem might be absolutely wrong though.
Feb 12 2014
prev sibling parent reply Martin Nowak <code dawg.eu> writes:
On 02/11/2014 11:32 AM, thedeemon wrote:

 Have you seen Dabble?
 https://github.com/callumenator/dabble
 It works pretty well on my Win 7.
I will try it again, there is a lot of recent activity. Last time it didn't work. https://github.com/callumenator/dabble/issues/1 I think it still misses an essential part. To make a real REPL one has to support importing of modules and linking, otherwise one can only imitate certain language constructs. For example it should be possible to call a function or inherit from a class that were defined earlier.
Feb 12 2014
parent "cal" <callumenator gmail.com> writes:
On Wednesday, 12 February 2014 at 18:08:11 UTC, Martin Nowak 
wrote:
 For example it should be possible to call a function or inherit 
 from a class that were defined earlier.
Dabble allows both of these things, if I understand your comment correctly.
Feb 12 2014
prev sibling next sibling parent reply "The Guest" <dontspammebro 338.org> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
http://dpaste.dzfl.pl/1969487a Works for me when playing around. Not sure we'll ever see a real D repl.
Feb 11 2014
parent "deadalnix" <deadalnix gmail.com> writes:
On Tuesday, 11 February 2014 at 13:11:06 UTC, The Guest wrote:
 On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak 
 wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
 |     return t.name;
 | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
http://dpaste.dzfl.pl/1969487a Works for me when playing around. Not sure we'll ever see a real D repl.
SDC is capable to JIT whatever D it support. That mean you can create a REPL fairly easily. This has been in my TODO list for a while, but supporting more feature is higher priority. Feel free to contact me is that is of interest for you (Martin, please do as well if you think it is worth it).
Feb 11 2014
prev sibling next sibling parent reply "MattCoder" <somekindofmonster email.com.br> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.
Interesting! I was playing around: D> write("test"); => undefined identifier write D> import std.stdio; => std D> write("test"); D> Shouldn't code above print "test"?
Feb 12 2014
parent reply Timothee Cour <thelastmammoth gmail.com> writes:
already added a bug report in github for that


On Wed, Feb 12, 2014 at 11:56 AM, MattCoder
<somekindofmonster email.com.br>wrote:

 On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:

 Barely running but already fun and a little useful.
Interesting! I was playing around: D> write("test"); => undefined identifier write D> import std.stdio; => std D> write("test"); D> Shouldn't code above print "test"?
Feb 12 2014
parent "MattCoder" <somekindofmonster email.com.br> writes:
On Wednesday, 12 February 2014 at 21:07:27 UTC, Timothee Cour
wrote:
 already added a bug report in github for that
Hmmm I should have checked the "issue list" first! Thanks for the info, Matheus.
Feb 12 2014
prev sibling next sibling parent "Brad Anderson" <eco gnuk.net> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
I'm kind of amazed how well this works. Awesome.
Feb 12 2014
prev sibling next sibling parent "Kelet" <kelethunter gmail.com> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
Excellent, I've been waiting for this. Even better than I expected as it has a nice web interface. All of my initial bugs have already been reported. Once this project (or perhaps dabble) is more mature, something like http://tryhaskell.org/ or http://tryruby.org/ may be a good idea.
Feb 12 2014
prev sibling next sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
It would be nice if in the online sandbox the window width could be changed.
Feb 13 2014
parent Martin Nowak <code dawg.eu> writes:
On 02/13/2014 10:40 AM, John Colvin wrote:
 It would be nice if in the online sandbox the window width could be
 changed.
https://github.com/MartinNowak/drepl/issues/23
Feb 21 2014
prev sibling next sibling parent reply "Tourist" <gravatar gravatar.com> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
http://i.imgur.com/LNYMNYw.png
Feb 13 2014
parent reply Rory McGuire <rjmcguire gmail.com> writes:
very cool


On Thu, Feb 13, 2014 at 12:27 PM, Tourist <gravatar gravatar.com> wrote:

 On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:

 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
http://i.imgur.com/LNYMNYw.png
Feb 13 2014
parent reply "Tourist" <gravatar gravatar.com> writes:
On Thursday, 13 February 2014 at 20:18:39 UTC, Rory McGuire wrote:
 very cool


 On Thu, Feb 13, 2014 at 12:27 PM, Tourist 
 <gravatar gravatar.com> wrote:

 On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak 
 wrote:

 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
http://i.imgur.com/LNYMNYw.png
Looks like you're being sarcastic. What I meant is that sending comments twice disconnects the server. I can reproduce it every time. Looks like a bug to me.
Feb 14 2014
next sibling parent Martin Nowak <code dawg.eu> writes:
On 02/14/2014 03:33 PM, Tourist wrote:
 I can reproduce it every time. Looks like a bug to me.
How about reporting a bug? https://github.com/MartinNowak/drepl/issues
Feb 16 2014
prev sibling next sibling parent Rory McGuire <rjmcguire gmail.com> writes:
hehe, sorry. I use GMail and your comment was the last comment so I ended
up commenting on your comment instead of the announcement.


On Fri, Feb 14, 2014 at 4:33 PM, Tourist <gravatar gravatar.com> wrote:
 Looks like you're being sarcastic.
 What I meant is that sending comments twice disconnects the server. I can
 reproduce it every time. Looks like a bug to me.
I too could reproduce that bug.
Feb 17 2014
prev sibling parent Martin Nowak <code dawg.eu> writes:
On 02/14/2014 03:33 PM, Tourist wrote:

Looks like you're being sarcastic. What I meant is that sending comments twice disconnects the server. I can reproduce it every time. Looks like a bug to me.
Please file bug reports. https://github.com/MartinNowak/drepl/issues https://github.com/MartinNowak/drepl/commit/7ec687ba342a04bff040630957bb10876d0ebb78 https://github.com/MartinNowak/drepl/commit/3eb953e91b29546a89c222cb4f9e8b9341dc1a47
Feb 21 2014
prev sibling next sibling parent reply "Asman01" <jckj33 gmail.com> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
Very nice! thanks. I tried the following code but it print nothing: auto twice = (int a) => 2*a; twice(2); What's wrong with that?
Feb 13 2014
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 14 February 2014 at 05:32:12 UTC, Asman01 wrote:
 On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak 
 wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
 |     return t.name;
 | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
Very nice! thanks. I tried the following code but it print nothing: auto twice = (int a) => 2*a; twice(2); What's wrong with that?
Drop the semicolon after twice(2)
Feb 14 2014
parent "Martin Nowak" <code dawg.eu> writes:
On Friday, 14 February 2014 at 11:58:43 UTC, John Colvin wrote:
 auto twice = (int a) => 2*a;
 twice(2);

 What's wrong with that?
Drop the semicolon after twice(2)
Yeah, with a semicolon it's a statement, so it doesn't have any result value to print. Without the semicolon it's an expression.
Feb 14 2014
prev sibling parent reply "cal" <callumenator gmail.com> writes:
On Tuesday, 11 February 2014 at 04:46:41 UTC, Martin Nowak wrote:
 Barely running but already fun and a little useful.

 Example:

 D> import std.algorithm, std.array, std.file;
 => std
 D> auto name(T)(T t) {
  |     return t.name;
  | }
 => name
 D> dirEntries(".", SpanMode.depth).map!name.join(", ")
 => ./drepl_sandbox
 D>

 https://github.com/MartinNowak/drepl
 http://drepl.dawg.eu/
This approach with separate modules is far superior to what I did with dabble, and much simpler. My target was windows initially, where I guess this won't work currently. Hopefully the situation there will improve soon.
Feb 14 2014
parent Martin Nowak <code dawg.eu> writes:
On 02/15/2014 12:29 AM, cal wrote:
 My target was windows initially, where I guess this won't work
 currently. Hopefully the situation there will improve soon.
Yes, we'll improve the Windows DLL support. At some point shared libraries should work equally well on all platforms. I also had a skype call with Benjamin about DIP45 yesterday. http://wiki.dlang.org/DIP45
Feb 16 2014