thisExePath purity
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Sep 19 17:37:39 PDT 2016
On 9/19/16 8:01 PM, crimaniak wrote:
> Hi!
>
> Is there situations when output of thisExePath() can be different during
> runtime? If yes, what the reason?
> If no, is this possible to mark it as pure in phobos?
>
> https://dlang.org/library/std/file/this_exe_path.html
Not in a way that D can ensure purity. Yes, it will not change. But that
guarantee is not communicated via the OS functions required to call to
get the information.
One thing you can do:
immutable string myPath;
shared static this()
{
import std.file: thisExePath;
myPath = thisExePath;
}
// now use myPath as required from pure functions.
-Steve
More information about the Digitalmars-d-learn
mailing list