April 16, 2005
Ah, Dave Fladebo also noticed pipe input streams weren't working and I forgot to look into it. sorry about that!

"Shawn Liu" <liuxuhong.cn@gmail.com> wrote in message news:d3rg18$149$1@digitaldaemon.com...
> File file = new File(hReadPipe, FileMode.In);
> while(!file.eof()){
>  String s = file.readLine();
>  if(s.length  == 0 )
>   break;
>  callback(s);
> }
> file.close();
>
> Maybe this occured at file.readLine();
>
>
> "Ben Hinkle" <ben.hinkle@gmail.com> :d3r7i4$2sm4$1@digitaldaemon.com...
>> Can post or send me some reproduction steps?
>> thanks
>> -Ben
>>
>> "Shawn Liu" <liuxuhong.cn@gmail.com> wrote in message news:d3qcgi$21vo$1@digitaldaemon.com...
>>>I still encounter a runtime error "Stream is not seekable". But the apps compiled with V0.119 don't encounter that.


April 17, 2005
"Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:d3r0cv$2nfb$1@digitaldaemon.com...
> Naturally I'd prefer not to duplicate the definition of FooException in
the
> different versions and instead have one definition that calls a common errno->string function (eg sysErrorString). It's cleaner IMO. But it's
your
> call...

But there can't be a common errno->string function, as C errno and Windows errno coexist, but are different.


April 17, 2005
"Regan Heath" <regan@netwin.co.nz> wrote in message news:opspbkbwa523k2f5@nrage.netwin.co.nz...
> On Fri, 15 Apr 2005 21:18:50 -0700, Walter <newshound@digitalmars.com> wrote:
> > I didn't think the two should be
> > conflated together. Some RTL's try to merge the two by having the
Windows
> > values negated, but that strikes me as a too-confusing kludge as well.
>
> Why is it confusing?
> People should never refer to the error codes by number, but rather by
> defined name eg.
>
> ENOENT - No such file or directory
> EEXIST - File exists

Because then people have to remember that there are two different errno's in the SysError, and that the negative ones are the negation of what Windows documents them to be. Those programmers who need to know what the error number is are probably not going to be too happy to find out they have to negate it. It'll inevitably get negated the wrong number of times, and the result will be irritating bugs.

Philosophically, I'm strongly opposed to fixing the operating system API. If D does, then D has the onerous and impossible task of re-documenting the OS interface (instead of just referring to the docs written by the OS vendor). I'll agree that the Windows designers should have been accommodating with the C errno and come up with a getLastErrno() that will coexist with it. But they didn't, and so it is what it is.


April 17, 2005
On Sat, 16 Apr 2005 20:21:59 -0700, Walter <newshound@digitalmars.com> wrote:
> "Regan Heath" <regan@netwin.co.nz> wrote in message
> news:opspbkbwa523k2f5@nrage.netwin.co.nz...
>> On Fri, 15 Apr 2005 21:18:50 -0700, Walter <newshound@digitalmars.com>
>> wrote:
>> > I didn't think the two should be
>> > conflated together. Some RTL's try to merge the two by having the
> Windows
>> > values negated, but that strikes me as a too-confusing kludge as well.
>>
>> Why is it confusing?
>> People should never refer to the error codes by number, but rather by
>> defined name eg.
>>
>> ENOENT - No such file or directory
>> EEXIST - File exists
>
> Because then people have to remember that there are two different errno's in
> the SysError, and that the negative ones are the negation of what Windows
> documents them to be. Those programmers who need to know what the error
> number is are probably not going to be too happy to find out they have to
> negate it. It'll inevitably get negated the wrong number of times, and the
> result will be irritating bugs.
>
> Philosophically, I'm strongly opposed to fixing the operating system API. If
> D does, then D has the onerous and impossible task of re-documenting the OS
> interface (instead of just referring to the docs written by the OS vendor).
> I'll agree that the Windows designers should have been accommodating with
> the C errno and come up with a getLastErrno() that will coexist with it. But
> they didn't, and so it is what it is.

Ok, fair enough, how about if I write some code to show how I believe it can be done, and you comment on that.

Regan
April 17, 2005
On Sat, 16 Apr 2005 20:07:24 -0700, Walter <newshound@digitalmars.com> wrote:
> "Ben Hinkle" <ben.hinkle@gmail.com> wrote in message
> news:d3r0cv$2nfb$1@digitaldaemon.com...
>> Naturally I'd prefer not to duplicate the definition of FooException in
> the
>> different versions and instead have one definition that calls a common
>> errno->string function (eg sysErrorString). It's cleaner IMO. But it's
> your
>> call...
>
> But there can't be a common errno->string function, as C errno and Windows errno coexist, but are different.

What do you mean by "Windows errno"? Are you referring to GetLastError()?

AFAIK calling strerror(errno) on any OS produces the correct error string.
Calling FormatMessage on GetLastError, or WSAGetLastError produces the correct error string.

Regan
April 17, 2005
"Walter" <newshound@digitalmars.com> wrote in message news:d3sk8r$qgo$1@digitaldaemon.com...
>
> "Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:d3r0cv$2nfb$1@digitaldaemon.com...
>> Naturally I'd prefer not to duplicate the definition of FooException in
> the
>> different versions and instead have one definition that calls a common errno->string function (eg sysErrorString). It's cleaner IMO. But it's
> your
>> call...
>
> But there can't be a common errno->string function, as C errno and Windows errno coexist, but are different.

By errno I mean errno on Linux and GetLastError on Windows.


April 17, 2005
On Sun, 17 Apr 2005 16:11:05 +1200, Regan Heath <regan@netwin.co.nz> wrote:
> On Sat, 16 Apr 2005 20:21:59 -0700, Walter <newshound@digitalmars.com> wrote:
>> "Regan Heath" <regan@netwin.co.nz> wrote in message news:opspbkbwa523k2f5@nrage.netwin.co.nz...
>>> On Fri, 15 Apr 2005 21:18:50 -0700, Walter <newshound@digitalmars.com> wrote:
>>> > I didn't think the two should be
>>> > conflated together. Some RTL's try to merge the two by having the
>> Windows
>>> > values negated, but that strikes me as a too-confusing kludge as
>>> well.
>>>
>>> Why is it confusing?
>>> People should never refer to the error codes by number, but rather by
>>> defined name eg.
>>>
>>> ENOENT - No such file or directory
>>> EEXIST - File exists
>>
>> Because then people have to remember that there are two different
>> errno's in
>> the SysError, and that the negative ones are the negation of what
>> Windows
>> documents them to be. Those programmers who need to know what the error
>> number is are probably not going to be too happy to find out they have
>> to
>> negate it. It'll inevitably get negated the wrong number of times, and
>> the
>> result will be irritating bugs.
>>
>> Philosophically, I'm strongly opposed to fixing the operating system
>> API. If
>> D does, then D has the onerous and impossible task of re-documenting
>> the OS
>> interface (instead of just referring to the docs written by the OS
>> vendor).
>> I'll agree that the Windows designers should have been accommodating
>> with
>> the C errno and come up with a getLastErrno() that will coexist with
>> it. But
>> they didn't, and so it is what it is.
>
> Ok, fair enough, how about if I write some code to show how I believe it can be done, and you comment on that.

Ok, so what do you think of this solution?
Other peoples input would be appreciated also.

Regan

April 17, 2005
"Regan Heath" <regan@netwin.co.nz> wrote in message news:opspczbht823k2f5@nrage.netwin.co.nz...
> On Sat, 16 Apr 2005 20:07:24 -0700, Walter <newshound@digitalmars.com> wrote:
> > "Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:d3r0cv$2nfb$1@digitaldaemon.com...
> >> Naturally I'd prefer not to duplicate the definition of FooException in
> > the
> >> different versions and instead have one definition that calls a common errno->string function (eg sysErrorString). It's cleaner IMO. But it's
> > your
> >> call...
> >
> > But there can't be a common errno->string function, as C errno and Windows errno coexist, but are different.
>
> What do you mean by "Windows errno"? Are you referring to GetLastError()?

That's right. You see, we're already confused about which error number we're talking about. That's why they can't be the same function <g>.

> AFAIK calling strerror(errno) on any OS produces the correct error string. Calling FormatMessage on GetLastError, or WSAGetLastError produces the correct error string.
>
> Regan


April 17, 2005
"Regan Heath" <regan@netwin.co.nz> wrote in message news:opspc69zdb23k2f5@nrage.netwin.co.nz...
> Ok, so what do you think of this solution?
> Other peoples input would be appreciated also.

I appreciate the effort you've put into this.

What's wrong with the setup in 0.121 Phobos? Why try to force a merge? Code that will generate a C errno is always going to be very different from code that generates a Windows getLastError(). Keep them parallel and distinct, and there shouldn't be any confusion about it.

Your method reserves the 'CUSTOM' value range. What if the user's application needs a custom value range? They can't use D. What if a D app links to a C dll that uses those values? It'll fail in mysterious ways.


April 17, 2005
"Walter" <newshound@digitalmars.com> wrote in message news:d3sk8r$qgo$1@digitaldaemon.com...
>
> "Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:d3r0cv$2nfb$1@digitaldaemon.com...
>> Naturally I'd prefer not to duplicate the definition of FooException in
> the
>> different versions and instead have one definition that calls a common errno->string function (eg sysErrorString). It's cleaner IMO. But it's
> your
>> call...
>
> But there can't be a common errno->string function, as C errno and Windows errno coexist, but are different.

I'm not sure what you mean by different. They have different errors and numbers and strings but the concept of mapping an error code to a string is independent of all that. More specifically, instead of std.file looking like

version(Windows) {
  class FileException {
     ...10 lines of code or so ...
     this(char[] x,uint errno) {
      this(x,sysErrorString(errno));
      ...
    }
  }
  ... Windows code ...
} else version (linux) {
  class FileException {
     ...same 10 lines of code as above ...
     this(char[] x,uint errno) {
      char* s = strerror(errno);
      this(x,<stringify>(s));
      ...
    }
  }
  ... Linux code ...
}

it should look like

  class FileException {
     ...10 lines of code or so ...
     this(char[] x,uint errno) {
      this(x,sysErrorString(errno));
      ...
    }
  }
 ... rest of std.file ...

and sysErrorString looks like

char[] sysErrorString(int errno) {
  version (Windows) {
    .. content of existing std.windows.syserror ...
  } else {
      char* s = strerror(errno);
      return <stringify>(s);
  }
}

It's just taking the exact same code you have and rearranging it to avoid code duplication. Everything else in std.file is exactly the same. The Windows code passes the result of GetLastError to the FileException ctor and the Linux version passes getErrno(); Why have every module that wants to use a system error copy and paste code? It's begging for the errno->string abstraction IMO.