Thread overview
Scripting in D on Windows
Jan 30, 2009
Sergey Gromov
Jan 30, 2009
Nick Sabalausky
Mar 01, 2009
hasen
January 30, 2009
It is possible to make .d files automatically executable on Windows.

For that you need:
1) modify the PATHEXT environment variable.  It's a semicolon-separated
list of executable extensions, so you just add ";.D" at the end
2) create a file association for .D and make the default action for it
of the form:

  dmd -run "%1" %*

Now if you have foo.d in your path, you just type 'foo' in command line and it runs.

OK, so far so good.  But the drawback of this is that every single .d file becomes executable which is absolutely not what I want.  I want only selected, specially designed D programs to be executed when I mention their name.  This would be possible if I used a different file extension for D scripts, .ds for instance.  Unfortunately DMD chokes on files with unknown extensions, making this impossible.

What do you think?  Would you use D for scripting?  Is it worth a feature request for DMD to support additional--or arbitrary--extensions for files executed with -run?
January 30, 2009
"Sergey Gromov" <snake.scaly@gmail.com> wrote in message news:1fknfu6vto1zn.q3hbrnp5lpsk.dlg@40tude.net...
> It is possible to make .d files automatically executable on Windows.
>
> For that you need:
> 1) modify the PATHEXT environment variable.  It's a semicolon-separated
> list of executable extensions, so you just add ";.D" at the end
> 2) create a file association for .D and make the default action for it
> of the form:
>
>  dmd -run "%1" %*
>
> Now if you have foo.d in your path, you just type 'foo' in command line and it runs.
>
> OK, so far so good.  But the drawback of this is that every single .d file becomes executable which is absolutely not what I want.  I want only selected, specially designed D programs to be executed when I mention their name.  This would be possible if I used a different file extension for D scripts, .ds for instance.  Unfortunately DMD chokes on files with unknown extensions, making this impossible.
>
> What do you think?  Would you use D for scripting?  Is it worth a feature request for DMD to support additional--or arbitrary--extensions for files executed with -run?

I'm of the mind that every language should be usable as both script and compiled. So in that sense, I like your proposal. Although, to be honest, I don't see much of a difference between doing that versus just simply compiling the d "script" to an executable and running that.


March 01, 2009
Sergey Gromov wrote:
> It is possible to make .d files automatically executable on Windows.
> 
> For that you need:
> 1) modify the PATHEXT environment variable.  It's a semicolon-separated
> list of executable extensions, so you just add ";.D" at the end
> 2) create a file association for .D and make the default action for it
> of the form:
> 
>   dmd -run "%1" %*
> 
> Now if you have foo.d in your path, you just type 'foo' in command line
> and it runs.
> 
> OK, so far so good.  But the drawback of this is that every single .d
> file becomes executable which is absolutely not what I want.  I want
> only selected, specially designed D programs to be executed when I
> mention their name.  This would be possible if I used a different file
> extension for D scripts, .ds for instance.  Unfortunately DMD chokes on
> files with unknown extensions, making this impossible.
> 
> What do you think?  Would you use D for scripting?  Is it worth a
> feature request for DMD to support additional--or arbitrary--extensions
> for files executed with -run?

I like the idea!

I think for general purpose scripting I'd rather use python, BUT the importance of this idea is that it abstracts away all the compilation stages!