www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D repl

reply "cal" <callumenator gmail.com> writes:
I uploaded a small demo of a D repl i've been playing with, might 
be of some interest. It's not a robust bit of code, and is not my 
idea of a proper repl, but shows some possibilities. The video 
shows the repl running as a web server (using vibe) with a 
browser client which adds some pretty.

Video is at: http://youtu.be/6Ycr4N1jb_g
Code is at:  https://github.com/callumenator/dabble

Note: the repl is windows only, as it uses Dll's and some custom 
loading code. When full dynamic loading support comes along, i 
guess it could run under linux, and probably be a bit more stable.
Jun 25 2013
next sibling parent reply "Tyro[17]" <ridimz yahoo.com> writes:
On 6/25/13 10:47 PM, cal wrote:
 I uploaded a small demo of a D repl i've been playing with, might be of
 some interest. It's not a robust bit of code, and is not my idea of a
 proper repl, but shows some possibilities. The video shows the repl
 running as a web server (using vibe) with a browser client which adds
 some pretty.

 Video is at: http://youtu.be/6Ycr4N1jb_g
 Code is at:  https://github.com/callumenator/dabble

 Note: the repl is windows only, as it uses Dll's and some custom loading
 code. When full dynamic loading support comes along, i guess it could
 run under linux, and probably be a bit more stable.
cal... thank you for working on and posting this. I could definitely using something like this to get more understanding of what goes on under the hood. Unfortunately I made a switch to *nix OSes (MAC OSX and and more recently Ubuntu) back in 2011 and have never looked back. Can't wait for *nix support to be implemented. You suggest that it is not your idea of a proper repl. Is there plans of returning to the drawing board to develop that idea from scratch? Eagerly, -- Andrew Edwards -------------------- http://www.akeron.co auto getAddress() { string location = " ", period = "."; return ("info" ~ location ~ "afidem" ~ period ~ "org"); }
Jun 25 2013
parent "cal" <callumenator gmail.com> writes:
On Wednesday, 26 June 2013 at 04:29:31 UTC, Tyro[17] wrote:
 You suggest that it is not your idea of a proper repl. Is there 
 plans of returning to the drawing board to develop that idea 
 from scratch?
I think a better solution IMO is to hook up a D front-end to LLVM's jit compiler, but I don't have any plans to do this. The method I used (compiling to Dll's and stuff) was simply the most expedient for me, I just wanted to see if it could work.
Jun 25 2013
prev sibling next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
It looks very nice. I like the interactive shell in Python and 
Haskell. Even languages like Scala enjoy it. The importance of a 
good REPL can't be underestimated. I'd like a good repl in the 
standard D distribution (despite the installation with dub is 
easy).

Notes:
- Regarding the input and output lines, I suggest to take a look 
at Mathematica and Sage. I think it's better to give numbers only 
to the inputs (or separate numbers to inputs and outputs), and to 
denote inputs and outputs differently. So there's no need for the 
"=>".
- print stringNums: very nice.
- .map!(a => a.to!string)  and .map!(a => S(a)) can also be 
written like this:

import std.stdio, std.algorithm, std.range, std.conv;
void main() {
     10.iota.map!text.writeln;
     static struct S { int x; }
     10.iota.map!S.writeln;
}

- is type x  the same as  print typeof(x)  ?
- line 29: foreach that prints the last result of the iteration: 
it's interesting.

I have followed the instructions:

git clone https://github.com/callumenator/dabble
cd dabble
dub build --config=console

But the compilation stops with the errors:

Running dmd (compile)...
...\dub\packages\pegged-master\pegged\dynamic\grammar.d(245): 
Error: not a property eps
...\dub\packages\pegged-master\pegged\dynamic\grammar.d(418): 
Error: not a property fail


I think DUB should print _where_ it copies files, and it should 
use a less hard to find place to stores them. (An optional idea 
is to store inside the directory of dub a link to the directory 
where dub stores those files).

Bye,
bearophile
Jun 26 2013
next sibling parent reply =?UTF-8?B?U8O2bmtlIEx1ZHdpZw==?= <sludwig outerproduct.org> writes:
Am 26.06.2013 14:19, schrieb bearophile:
 Running dmd (compile)...
 ...\dub\packages\pegged-master\pegged\dynamic\grammar.d(245): Error: 
not a property eps
 ...\dub\packages\pegged-master\pegged\dynamic\grammar.d(418): Error: 
not a property fail Do you have the latest version of DUB installed? It looks like -property was specified on the compiler command line (checkable with "dub -v"). This was removed recently after Jonathan convinced me that it is worthless to support, since all recent property related DIPs make parenthesis optional and it seems pretty clear that this will be the way forward.
 I think DUB should print _where_ it copies files, and it should use a 
less hard to find place to stores them. (An optional idea is to store inside the directory of dub a link to the directory where dub stores those files). I agree. You can look it up using "dub list-installed", but it should also print that at installation time.
Jun 26 2013
parent "bearophile" <bearophileHUGS lycos.com> writes:
Sönke Ludwig:

 Do you have the latest version of DUB installed?
I have installed it right to try the D repl. I have installed the latest Windows version here, precompiled binaries (I think that it's better to show only the latest versions in a table, and all the older versions in a different and less visible table): http://registry.vibed.org/download
 This was removed recently after Jonathan convinced me that it 
 is worthless to support, since all recent property related DIPs 
 make parenthesis optional and it seems pretty clear that this 
 will be the way forward.
I have stopped compiling my code with -property since some months, despite as Jonathan I kind of liked it :-) Bye, bearophile
Jun 26 2013
prev sibling parent reply "cal" <callumenator gmail.com> writes:
On Wednesday, 26 June 2013 at 12:19:35 UTC, bearophile wrote:
 - is type x  the same as  print typeof(x)  ?
No, when it first compiles a user-defined type, the repl recursively maps out the type's structure. It does this to allow using 'print/type' without needing to do a compile, since these are done fairly often.
 I have followed the instructions:

 git clone https://github.com/callumenator/dabble
 cd dabble
 dub build --config=console

 But the compilation stops with the errors:

 Running dmd (compile)...
 ...\dub\packages\pegged-master\pegged\dynamic\grammar.d(245): 
 Error: not a property eps
 ...\dub\packages\pegged-master\pegged\dynamic\grammar.d(418): 
 Error: not a property fail
What compiler version are you using? I'm not seeing any problems with 2.063, I haven't tried a more recent version yet. Thanks for comments!
Jun 26 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
cal:

 What compiler version are you using? I'm not seeing any 
 problems with 2.063, I haven't tried a more recent version yet.
I am using dmd, and I compile it almost daily. I suspect it's not a matter of compiler version, but it's a matter of dub using or not using -property in compiling code. Bye, bearophile
Jun 26 2013
parent "cal" <callumenator gmail.com> writes:
On Thursday, 27 June 2013 at 00:13:29 UTC, bearophile wrote:
 cal:

 What compiler version are you using? I'm not seeing any 
 problems with 2.063, I haven't tried a more recent version yet.
I am using dmd, and I compile it almost daily. I suspect it's not a matter of compiler version, but it's a matter of dub using or not using -property in compiling code. Bye, bearophile
With dmd built from git-head I can reproduce this. It will take a little while to resolve, and push this to Pegged master. DMD 2.063 release works ok in the meantime.
Jun 26 2013
prev sibling next sibling parent David <d dav1d.de> writes:
Am 26.06.2013 04:47, schrieb cal:
 I uploaded a small demo of a D repl i've been playing with, might be of
 some interest. It's not a robust bit of code, and is not my idea of a
 proper repl, but shows some possibilities. The video shows the repl
 running as a web server (using vibe) with a browser client which adds
 some pretty.
 
 Video is at: http://youtu.be/6Ycr4N1jb_g
 Code is at:  https://github.com/callumenator/dabble
 
 Note: the repl is windows only, as it uses Dll's and some custom loading
 code. When full dynamic loading support comes along, i guess it could
 run under linux, and probably be a bit more stable.
This is really cool. Nothing more to say!
Jun 26 2013
prev sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
cal:

 I uploaded a small demo of a D repl i've been playing with,
In past I have seen D repls, they come and then they fade away, regardless how much work they have required to be created, or how much refined they are. The fact they have appeared more than once shows some persons desire them. Yet, I see no comments from Walter or Andrei. I think a repl needs to be inside the standard D distribution, it's not an external toy meant to be forgotten, it's one essential tool for D development, like a profiler, debugger, or rdmd :-) Bye, bearophile
Jun 30 2013
next sibling parent "MattCoder" <mattcoder hotmail.com> writes:
On Sunday, 30 June 2013 at 13:31:02 UTC, bearophile wrote:
 cal:

 I uploaded a small demo of a D repl i've been playing with,
In past I have seen D repls, they come and then they fade away, regardless how much work they have required to be created, or how much refined they are. The fact they have appeared more than once shows some persons desire them. Yet, I see no comments from Walter or Andrei. I think a repl needs to be inside the standard D distribution, it's not an external toy meant to be forgotten, it's one essential tool for D development, like a profiler, debugger, or rdmd :-) Bye, bearophile
+1 Matheus.
Jun 30 2013
prev sibling next sibling parent reply "SomeDude" <lovelydear mailmetrash.com> writes:
On Sunday, 30 June 2013 at 13:31:02 UTC, bearophile wrote:
 cal:

 I uploaded a small demo of a D repl i've been playing with,
In past I have seen D repls, they come and then they fade away, regardless how much work they have required to be created, or how much refined they are. The fact they have appeared more than once shows some persons desire them. Yet, I see no comments from Walter or Andrei. I think a repl needs to be inside the standard D distribution, it's not an external toy meant to be forgotten, it's one essential tool for D development, like a profiler, debugger, or rdmd :-) Bye, bearophile
It's cool, but it's yet another tool to maintain. Thus their lack of enthusiasm I guess. Unless someone comes forward and is ready to maintain the repl, in which case I think everyone would applaud.
Jun 30 2013
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
SomeDude:

 It's cool, but it's yet another tool to maintain. Thus their 
 lack of enthusiasm I guess. Unless someone comes forward and is 
 ready to maintain the repl, in which case I think everyone 
 would applaud.
I understand and I agree, thank you for putting me back on the ground. Also, I remember that today they add things to the Python standard library only when they are already widely used (unless they are created by people like Hettinger). So maybe it's better to see one D repl used a lot in the wild a lot, and only then add it to the standard distribution. Bye, bearophile
Jun 30 2013
parent "SomeDude" <lovelydear mailmetrash.com> writes:
On Sunday, 30 June 2013 at 15:35:11 UTC, bearophile wrote:
 SomeDude:

 It's cool, but it's yet another tool to maintain. Thus their 
 lack of enthusiasm I guess. Unless someone comes forward and 
 is ready to maintain the repl, in which case I think everyone 
 would applaud.
I understand and I agree, thank you for putting me back on the ground.
Sorry for that. ;) I just saw the video and it looks really awesome indeed. Also, I remember that today they add things to the
 Python standard library only when they are already widely used 
 (unless they are created by people like Hettinger). So maybe 
 it's better to see one D repl used a lot in the wild a lot, and 
 only then add it to the standard distribution.

 Bye,
 bearophile
Yeah, it probably needs a little testing before being included once for all.
Jun 30 2013
prev sibling parent reply "deadalnix" <deadalnix gmail.com> writes:
On Sunday, 30 June 2013 at 15:31:19 UTC, SomeDude wrote:
 On Sunday, 30 June 2013 at 13:31:02 UTC, bearophile wrote:
 cal:

 I uploaded a small demo of a D repl i've been playing with,
In past I have seen D repls, they come and then they fade away, regardless how much work they have required to be created, or how much refined they are. The fact they have appeared more than once shows some persons desire them. Yet, I see no comments from Walter or Andrei. I think a repl needs to be inside the standard D distribution, it's not an external toy meant to be forgotten, it's one essential tool for D development, like a profiler, debugger, or rdmd :-) Bye, bearophile
It's cool, but it's yet another tool to maintain. Thus their lack of enthusiasm I guess. Unless someone comes forward and is ready to maintain the repl, in which case I think everyone would applaud.
Compiler as a library, usual rant, no need to repeat.
Jun 30 2013
parent Jacob Carlborg <doob me.com> writes:
On 2013-06-30 20:00, deadalnix wrote:

 Compiler as a library, usual rant, no need to repeat.
Agree. -- /Jacob Carlborg
Jun 30 2013
prev sibling parent reply David <d dav1d.de> writes:
Am 30.06.2013 15:31, schrieb bearophile:
 cal:
 
 I uploaded a small demo of a D repl i've been playing with,
In past I have seen D repls, they come and then they fade away, regardless how much work they have required to be created, or how much refined they are. The fact they have appeared more than once shows some persons desire them. Yet, I see no comments from Walter or Andrei. I think a repl needs to be inside the standard D distribution, it's not an external toy meant to be forgotten, it's one essential tool for D development, like a profiler, debugger, or rdmd :-) Bye, bearophile
Crazy idea... CTFE is basically done with a D interpreter isn't it? Can't this be used as library to implement a REPL?
Jun 30 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
David:

 Crazy idea... CTFE is basically done with a D interpreter isn't 
 it?
 Can't this be used as library to implement a REPL?
In a REPL you want persistent state too. CTFE deletes its state once it's done. And in a past request of mine I've seen that Walter is against Bye, bearophile
Jun 30 2013
next sibling parent reply "Dicebot" <public dicebot.lv> writes:
On Sunday, 30 June 2013 at 16:36:42 UTC, bearophile wrote:
 And in a past request of mine I've seen that Walter is against 

Can you link his comment? That sounds weird.
Jun 30 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Dicebot:

 Can you link his comment? That sounds weird.
It was years ago, maybe more than three years ago. It's not easy to find. I have found discussions about this topic, but not comments from Walter: http://www.digitalmars.com/d/archives/digitalmars/D/D_Compiler_as_a_Library_164027.html http://www.digitalmars.com/d/archives/digitalmars/D/Compiler_as_a_service_in_C_4.0_104405.html Later I have found this (from 2009), where Walter gives me an answer, about D compiler as a DLL: http://www.digitalmars.com/d/archives/digitalmars/D/Compiler_as_dll_82715.html Bye, bearophile
Jun 30 2013
next sibling parent "Dicebot" <public dicebot.lv> writes:
Well, at least point about testing does not really matter anymore 
- it is automated ;) I wonder what Walter does think about it now 
- libclang has pretty much proven how awesome compiler front-end 
as library can be. Was one of main reasons for me to switch from 
gcc for daily C++ stuff.

On Sunday, 30 June 2013 at 16:59:12 UTC, bearophile wrote:
 Later I have found this (from 2009), where Walter gives me an 
 answer, about D compiler as a DLL:

 http://www.digitalmars.com/d/archives/digitalmars/D/Compiler_as_dll_82715.html

 Bye,
 bearophile
Jun 30 2013
prev sibling parent "Daniel Murphy" <yebblies nospamgmail.com> writes:
"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:aknmrnhodledtmfyphwd forum.dlang.org...
 Dicebot:

 Can you link his comment? That sounds weird.
It was years ago, maybe more than three years ago. It's not easy to find. I have found discussions about this topic, but not comments from Walter: http://www.digitalmars.com/d/archives/digitalmars/D/D_Compiler_as_a_Library_164027.html http://www.digitalmars.com/d/archives/digitalmars/D/Compiler_as_a_service_in_C_4.0_104405.html Later I have found this (from 2009), where Walter gives me an answer, about D compiler as a DLL: http://www.digitalmars.com/d/archives/digitalmars/D/Compiler_as_dll_82715.html
Things have changed a lot since 2009. This is definitely the way things are headed. First step: port the compiler to D.
Jul 01 2013
prev sibling parent David <d dav1d.de> writes:
Am 30.06.2013 18:36, schrieb bearophile:
 David:
 
 Crazy idea... CTFE is basically done with a D interpreter isn't it?
 Can't this be used as library to implement a REPL?
In a REPL you want persistent state too. CTFE deletes its state once it's done.
Yeah I know, but having a complete D interpreter as basis, this shouldn't be too hard to implement.
Jun 30 2013