Re: thisExePath purity

2016-09-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/20/16 3:42 PM, crimaniak wrote: On Tuesday, 20 September 2016 at 13:35:27 UTC, Steven Schveighoffer wrote: Note that if you don't import the module that contains the static ctor, it should be trimmed by the linker. Let's imagine linker can trim even imported module with static ctor, if

Re: thisExePath purity

2016-09-20 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 13:35:27 UTC, Steven Schveighoffer wrote: Yes, but if your code does instantiate it, it is called, even if you don't ever call the function that calls it. Yes, it's not ideal but better then just global variable and static block - it's called in any case, even

Re: thisExePath purity

2016-09-20 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 09:14:39 UTC, Marc Schütz wrote: Have a look at `std.concurrency.initOnce`: https://dlang.org/phobos/std_concurrency.html#.initOnce But you will still need to use assumePure() for calling `thisExePath`, and it might do other things that are impure... Yes,

Re: thisExePath purity

2016-09-20 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 04:26:05 UTC, Jonathan M Davis wrote: On Tuesday, September 20, 2016 04:17:21 crimaniak via Digitalmars-d-learn wrote: static shared immutable ReturnType!T value; I would point out that immutable is implicitly shared, so there's no reason to put

Re: thisExePath purity

2016-09-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/20/16 12:17 AM, crimaniak wrote: Hi and thanks all! On Tuesday, 20 September 2016 at 00:43:10 UTC, Jonathan M Davis wrote: immutable string executablePath; shared static this() { import std.file : thisExePath(); executablePath = thisExePath(); } This code is good for my needs

Re: thisExePath purity

2016-09-20 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 04:17:21 UTC, crimaniak wrote: Hi and thanks all! On Tuesday, 20 September 2016 at 00:43:10 UTC, Jonathan M Davis wrote: immutable string executablePath; shared static this() { import std.file : thisExePath(); executablePath = thisExePath(); }

Re: thisExePath purity

2016-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 20, 2016 04:17:21 crimaniak via Digitalmars-d-learn wrote: > static shared immutable ReturnType!T value; I would point out that immutable is implicitly shared, so there's no reason to put shared on an immutable variable. However, you _do_ want to put shared on a

Re: thisExePath purity

2016-09-19 Thread crimaniak via Digitalmars-d-learn
Hi and thanks all! On Tuesday, 20 September 2016 at 00:43:10 UTC, Jonathan M Davis wrote: immutable string executablePath; shared static this() { import std.file : thisExePath(); executablePath = thisExePath(); } This code is good for my needs but I start to think about how to

Re: thisExePath purity

2016-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 20, 2016 00:37:10 Stefan Koch via Digitalmars-d-learn wrote: > On Tuesday, 20 September 2016 at 00:01:58 UTC, crimaniak wrote: > > Hi! > > > > Is there situations when output of thisExePath() can be > > different during runtime? If yes, what the reason? > > If no, is this

Re: thisExePath purity

2016-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 20, 2016 00:01:58 crimaniak via Digitalmars-d-learn 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? > >

Re: thisExePath purity

2016-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
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

Re: thisExePath purity

2016-09-19 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 00:01:58 UTC, 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 No way

thisExePath purity

2016-09-19 Thread crimaniak via Digitalmars-d-learn
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