in reply to Re^10: Best way to handle readline errors? (perl 6?)
in thread Best way to handle readline errors?

Perl 6 pretty much solves the "errno" problem by using "interesting values of undef" to convey the reason the undef is undefined, if you happen to call something like readline in a scalar context. However, most such generators will be called using for rather than while, which will naturally distinguish end of list from exceptions that should be thrown, since the default action in Perl 6 is to throw an exception when it is determined that no one is checking for it directly, and generators used in list context don't generally want to poke exceptions into the list. Other interesting changes in Perl 6 include the fact that $! is lexically scoped, not a global alias to errno. Error values are propagated to an outer dynamic scope's $! when the decision is made whether to throw an exception or return an unthrown exception. It is hoped that this will prevent all the problems of trying to shadow C's idea of errno directly, since that's arguably one of the areas where the design of Unix was rather botched in the name of simplicity. Also, by and large, $! is treated as merely informative and useful for interpolation, but the actual underlying mechanisms do not rely on it directly, since the actual information is in whatever exception is propagating, either by explicitly being thrown, or by being returned in an interesting undef. $! is viewed as merely a handy reference to whatever the "current" error is.
  • Comment on Re^11: Best way to handle readline errors? (perl 6?)