August 07, 2014
> Sent: Thursday, August 07, 2014 at 11:03 AM
> From: "Lars Tandle Kyllingstad via phobos" <phobos@puremagic.com>
> To: "Phobos mailing list" <phobos@puremagic.com>
> Subject: Re: [phobos] std.process deprecations
>
> Inefficiency was never used as an argument.  The problem is that exec* does different things on Windows and POSIX.  In other words, a D program which uses std.process.exec* will have different observable behaviour on different platforms.  This is what bothers me.
>
>    - On POSIX systems, exec* overwrites the current process
>      with a new one.
>
>    - On Windows, exec* spawns a new, independent process and
>      exits the current one.
>

If they don't do the same thing on both platforms, then they shouldn't be the same function. That totally breaks portability. Phobos functions should be portable unless they're versioned to a specific OS. We may be stuck with slightly different behavior on different OSes in some cases, but we should be _very_ leery of it and try to avoid it as much as possible. Doing otherwise is just begging for bugs.

It sounds like we should provide the functionality for both systems, but if anyone is currently using these functions and expecting them to work the same on both systems, they could be in for a big shock. So, these functions should probably be replaced with system-specific versions for both POSIX and Windows - be that in different modules or in the same module with different names.

- Jonathan M Davis
_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
August 07, 2014
On 8/7/14, 11:03 AM, Lars Tandle Kyllingstad via phobos wrote:
> Program that behaves in the same manner, after exec* deprecation on
> Windows:
>
>      auto cmd = [ "prog", "arg1", "arg2" ];
>      version (Posix) execv(cmd[0], cmd[1 .. $]);
>      else { spawnProcess(cmd); _exit(0); }
>
> Somewhat improved program that appears to behave in almost the same
> manner on all platforms (assuming there are no other threads running!):
>
>      auto cmd = [ "prog", "arg1", "arg2" ];
>      version (Posix) execv(cmd[0], cmd[1 .. $]);
>      else _exit(wait(spawnProcess(cmd)));

Well I guess that's acceptable. Thanks. -- Andrei
_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
August 07, 2014
On 07/08/14 20:20, Jonathan M Davis via phobos wrote:

> If they don't do the same thing on both platforms, then they shouldn't be the
> same function. That totally breaks portability. Phobos functions should be
> portable unless they're versioned to a specific OS. We may be stuck with
> slightly different behavior on different OSes in some cases, but we should be
> _very_ leery of it and try to avoid it as much as possible. Doing otherwise
> is just begging for bugs.

My point exactly.

> It sounds like we should provide the functionality for both systems, but if
> anyone is currently using these functions and expecting them to work the same
> on both systems, they could be in for a big shock. So, these functions should
> probably be replaced with system-specific versions for both POSIX and Windows
> - be that in different modules or in the same module with different names.

I don't think we should provide that functionality on Windows at all, because it would just be a thin wrapper around the following:

    spawnProcess(...);
    _exit(0);

Keeping it around will just confuse people into thinking that it does something more or different.

Lars
_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
August 07, 2014
On 8/7/14, 11:47 AM, Lars Tandle Kyllingstad via phobos wrote:
> I don't think we should provide that functionality on Windows at all,
> because it would just be a thin wrapper around the following:
>
>      spawnProcess(...);
>      _exit(0);
>
> Keeping it around will just confuse people into thinking that it does
> something more or different.

I think this becomes a documentation matter. Please accompany the deprecation with documentation indicating how people can achieve effects similar, but not identical, to exec*() on Windows.

Andrei

_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
August 07, 2014
On 07/08/14 20:20, Andrei Alexandrescu wrote:
> On 8/7/14, 11:03 AM, Lars Tandle Kyllingstad via phobos wrote:
>>
>> [Extremely convincing arguments omitted]
>
> Well I guess that's acceptable. Thanks. -- Andrei

Awesome! :)

Next order of business:  Improving the exec* API.  The following is an excerpt from the documentation:

    int execv(in string pathname, in string[] argv);
    [...]
    Typically, the first element of argv is the command being executed,
    i.e. argv[0] == pathname.
    [...]
    Returns -1 on failure with no indication of the underlying error.

I find this extremely unsatisfying. First of all, there is really no need to repeat pathname in argv, and secondly, the functions could easily throw an exception with an informational error message based on errno.

I suggest deprecating these functions on POSIX too, and creating new, POSIX-only functions with equivalent functionality but an improved API.

Thoughts?  Is it worth it?

Lars
_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
August 07, 2014
On 07/08/14 21:02, Andrei Alexandrescu wrote:
> I think this becomes a documentation matter. Please accompany the
> deprecation with documentation indicating how people can achieve effects
> similar, but not identical, to exec*() on Windows.

I'm on it!

_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
August 07, 2014
I'd say we're good as we are. I agree repeating the argument is kind of meh but these are venerable functions instantly recognizable by many. Deprecating them in favor of new ones with minor cosmetic deltas gets close to wankery real quick. -- Andrei

On 8/7/14, 12:04 PM, Lars Tandle Kyllingstad via phobos wrote:
> On 07/08/14 20:20, Andrei Alexandrescu wrote:
>> On 8/7/14, 11:03 AM, Lars Tandle Kyllingstad via phobos wrote:
>>>
>>> [Extremely convincing arguments omitted]
>>
>> Well I guess that's acceptable. Thanks. -- Andrei
>
> Awesome! :)
>
> Next order of business:  Improving the exec* API.  The following is an
> excerpt from the documentation:
>
>      int execv(in string pathname, in string[] argv);
>      [...]
>      Typically, the first element of argv is the command being executed,
>      i.e. argv[0] == pathname.
>      [...]
>      Returns -1 on failure with no indication of the underlying error.
>
> I find this extremely unsatisfying. First of all, there is really no
> need to repeat pathname in argv, and secondly, the functions could
> easily throw an exception with an informational error message based on
> errno.
>
> I suggest deprecating these functions on POSIX too, and creating new,
> POSIX-only functions with equivalent functionality but an improved API.
>
> Thoughts?  Is it worth it?
>
> Lars
> _______________________________________________
> phobos mailing list
> phobos@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
August 07, 2014
On 07/08/14 21:29, Andrei Alexandrescu wrote:
> I'd say we're good as we are. I agree repeating the argument is kind of
> meh but these are venerable functions instantly recognizable by many.
> Deprecating them in favor of new ones with minor cosmetic deltas gets
> close to wankery real quick. -- Andrei

I would say that proper error handling is more than a cosmetic delta.
_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos
1 2
Next ›   Last »