run.dlang.io - a modern way to run D code

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Dec 14 00:59:00 UTC 2017


On Thu, Dec 14, 2017 at 12:22:15AM +0000, Meta via Digitalmars-d-announce wrote:
> On Wednesday, 13 December 2017 at 00:54:07 UTC, H. S. Teoh wrote:
> > On Wed, Dec 13, 2017 at 12:50:40AM +0000, Meta via
> > Digitalmars-d-announce wrote:
> > > On Tuesday, 12 December 2017 at 18:37:38 UTC, Seb wrote:
> > > > After it has been in stealth mode for quite a while, I'm happy
> > > > to announce that there's https://run.dlang.io
> > [...]
> > > This is a real life saver considering dpaste is blocked at work.
> > > It gets very tedious having to create a file, invoke the compiler,
> > > and run it in 3 separate steps just to test out some quick
> > > snippet.
> > 
> > Can't you just do:
> > 
> > 	rdmd --eval='<insert code here>'
[...]
> This works for short snippets that are one-off but I usually like to
> play around with a piece of code and that gets tedious as well trying
> to edit it on the command line. Not to mention trying to get quotation
> marks to match up and escape them correctly.

If you need to edit the code, you might as well use an editor anyway,
and if you use a Real Editor (:-P) like vim or emacs you *could* just
bind a single keystroke to invoking `dmd -run`.

Or better yet, use the new `dmd -` to compile the code directly from the
editor buffer via stdin, with `-of` set to some generic filename (I like
to use /tmp/text or /tmp/x, for example), then your keybinding could be
something like `| dmd - -of /tmp/test && ./test`.  Then you could
literally execute the editor buffer with one keystroke.  And this works
even when you're offline.

Sadly, `dmd - -run` currently doesn't quite work just yet. I should look
into fixing that.  And *then* we wouldn't need to invent a temporary
filename for the executable in our keybinding.

(Of course, none of this negates the value of run.dlang.io -- I'm not
arguing against that. It's just that testing out quick snippets seems to
be a flimsy excuse to need to use it. :-P)


T

-- 
Heads I win, tails you lose.


More information about the Digitalmars-d-announce mailing list