On Thursday, 11 July 2019 at 10:41:38 UTC, Alex wrote:
On Thursday, 11 July 2019 at 09:43:55 UTC, BoQsc wrote:
Here I have a file named: module.d

[...]

There is no main() function since, I want to import this module, into another .d file.

( If I try to import and module.d does have main() function I get this error: )
[...]





I would like to launch function "interestingFunction()" directly using rdmd.
Is it possible to achieve that by any way?





I tried to launch the whole file, but it gave me some weird output:
[...]

If you are trying to test a function separately from other functions, e.g. for testing, then you are approaching unit testing. You could write a unit test block just under the function to test like
unittest
{
  interestingFunction;
}

and launch it via rdmd... don't know the syntax right now. But here is something:
https://stackoverflow.com/questions/10694994/rdmd-is-not-running-unit-tests

So, I assume something like
rdmd -unittest --main module.d

Hmm, maybe I'll just rename module.d to module_library.d and place it in a folder, then create a new module_run.d file that would launch the functions of module_library.d

module\module_library.d
module\module_run.d
README.md

Maybe even place a README.md file explaining how I come up with this idea.

And when in need of executing it, I'll just type:
rdmd module\module_run.d

Reply via email to