Marcus Holland-Moritz wrote:
On 2004-03-02, at 18:26:33 +0000, Nick Ing-Simmons wrote:


Marcus Holland-Moritz <[EMAIL PROTECTED]> writes:

Core perl uses magic macro to set errno
which IIRC does back convert to native error code
on VMS and Win32 ?

Yes, but there's no way (that I could see) to set the PV slot in $! to a user-defined string. You can assign any number to $!, but that's almost useless:

[EMAIL PROTECTED] ~ $ perl -e '$!=4711;print"$!\n"'
Unknown error 4711

Furthermore, the whole concept of Errno and %! wouldn't work.

So you have to set errno to one of the known values, and have a resonable idea what message you get.


Exactly. :)


So: EINVAL
EBADF
EAGAIN
EWOULDBLOCK


yeild fairly generic messages.
Linux has a lot of exotic ones but they ain't portable.


You could probably check which keys are in %! at Makefile.PL time,
and use more specific messages where available. But I don't think
that would help very much.

So what we are supposed to do if we want to keep the idimatic perl working?


Consider:

open my $fh, "</tmp/bar" or die "$!";

now if I want to implement a perlio layer, I want this to work just the same:

open my $fh, "<:mylayer" or die "$!";

How do I set $! then? perlio doesn't provide a framework to set $!, just return codes.

At the moment the only option is to croak. But that totally breaks idiomatic perl, making the API kludgy as you need to eval {} every statement if you want to trap the error yourself.

Or is introducing a new $! variable like DBI::errstr a better way? It works for DBI since it provides a new API. Whereas with perlio the API doesn't change from the core API, but error handling is totally different.

can't we attach a different magic to $!, which will override ERRNO magic, if the former exists?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Reply via email to