[#4595] New block syntax — Daniel Amelang <daniel.amelang@...>

I'm really sorry if this isn't the place to talk about this. I've

25 messages 2005/03/21
[#4606] Re: New block syntax — "David A. Black" <dblack@...> 2005/03/21

Hi --

[#4629] Re: New block syntax — "Sean E. Russell" <ser@...> 2005/03/30

On Monday 21 March 2005 16:17, David A. Black wrote:

[#4648] about REXML::Encoding — speakillof <speakillof@...>

Hi.

15 messages 2005/03/31
[#4659] Re: about REXML::Encoding — "Sean E. Russell" <ser@...> 2005/04/04

On Thursday 31 March 2005 09:44, speakillof wrote:

Re: Undefined Errno::EPROTO and the like raises NameError

From: Sam Roberts <sroberts@...>
Date: 2005-03-08 02:13:57 UTC
List: ruby-core #4527
Quoting matz@ruby-lang.org, on Tue, Mar 08, 2005 at 10:03:16AM +0900:
> Hi,
> 
> In message "Re: Undefined Errno::EPROTO and the like raises NameError"
>     on Tue, 8 Mar 2005 01:17:37 +0900, "Florian Frank" <flori@nixe.ping.de> writes:
> 
> |I just run into the problem, that certain System Call Errors aren't 
> |defined depending on the platform. I tested on a platform, where 
> |Errno::EPROTO is not defined. If I code something like
> 
> Yeah, it's on my to-do list for a long time, but without any idea to
> solve.  Errno exceptions vary platform to platform, so that simple
> scripts like you did cause NameError, but I don't want to allow
> reference to undefined constants in the rescue clause, since relaxing
> constant reference here changes the meaning of expression, and makes
> semantics more complex.  Any idea?

I used to think like Florian, but now I think it is better the way it is
right now.

It seems like it makes it hard to be cross platform, but in a way it
makes it easier. If you have


  rescue Errno:EPROTO
    ...

and expect it to do something, and then run it on a platform that uses a
different errno than EPROTO for the condition, your code will silently
"seem" to work, but actually it works wrongly. For example, I just
looked and there is no EPROTO I see for Mac OS X, so I don't know what
it means, it must be a different error number on OS X.

It is better for your code to fail, then you will look at the man page
and realize that on this platform you need to rescue a different errno.

Another example is setting socket option REUSEPORT. It doesn't exist on
all platforms, and on the ones it doesn't, you need to set a different
socket option. If socket.c defined SOREUSEPORT, crazy things would
happen, but not what you wanted!

I think error numbers shouldn't be different from the other OS-specific
constants, like those in socket.c.

Cheers,
Sam


In This Thread