Making an .exe that executes source file inside itself.
BoQsc
vaidas.boqsc at gmail.com
Thu Apr 26 06:18:25 UTC 2018
On Wednesday, 25 April 2018 at 20:44:10 UTC, u0_a183 wrote:
> On Wednesday, 25 April 2018 at 19:54:26 UTC, BoQsc wrote:
>> On Wednesday, 25 April 2018 at 19:43:31 UTC, Jonathan M Davis
>> wrote:
>>> On Wednesday, April 25, 2018 19:19:58 BoQsc via
>>> Digitalmars-d-learn wrote:
>>>> So there has been idea I've got for around few months now:
>>>> making
>>>> a software which executable would contain a source file.
>>>> A software that anyone could modify by opening an executable
>>>> and
>>>> quickly change a few lines of it, rerun an executable, see
>>>> the
>>>> changes.
>>>>
>>>> Could this be easily possible with D language, considering
>>>> that sources files can be ran without long slow compilation
>>>> process?
>>>
>>> The normal way to do that is to just write a script. In the
>>> case of D, you can just use rdmd to do it. e.g. if you're on
>>> a POSIX system, just put
>>>
>>> #!/usr/bin/env rdmd
>>>
>>> at the top of your .d file and chmod it so that it's
>>> executable, and it'll run like any other script.
>>>
>>> - Jonathan M Davis
>>
>> Thank you Jonathan for a response.
>> I was aware of this, and it certainly perfectly works where
>> command line/terminal interface is the main tool to control
>> the system, a good example would be linux/gnu distributions
>> and macOS.
>> However in Windows while installing D language, I noticed that
>> .d source file extension is not associated with neither D
>> compiler (dmd.exe) nor D script interpretator (rdmd.exe)
>> So they can't be ran directly by clicking on those, nor they
>> have any icons that show that these source codes are actually
>> executable. This is a huge problem, because people that are
>> not aware of D language migh be harder to understand that
>> source script could be executable, at least - without help
>> from some more experienced user.
>
> If the purpose is to make scripts run by clicking them you can
> assign a file type to .d files.
>
> On Windows 10.
> https://www.digitaltrends.com/computing/how-to-set-default-programs-and-file-types-in-windows-10/
>
> Doing so would make the script engine the default program
> instead of a text editor so you might not want to. Or maybe
> assign .dxe and changing the filename before running.
Executable has executable file type for a reason - it
self-implies that the main function of the file - is to be
executed.
The problem with making source code files executable is that,
source code files, might not always be monolithic executable
code, but a part of a bigger interconnected program.
That would lead to partily working program execution, and most of
the times guess work of whether source code file was supposed to
be executed.
The clear alternative would be: .exe file on which, if
rightclicked - would open context menu showing posibility of
"edit/improve this executable". Which would not create additional
problem mentioned above.
More information about the Digitalmars-d-learn
mailing list