On Sun, Jun 12, 2005 at 12:52:03AM -0400, William Coleda wrote:
> open currently returns an Undef PMC if it fails to open a file. Should it 
> instead return a None? Or, IMO, a Null?

Undef PMC ... or more precisely, any old PMC value that is not
defined() ...  seems the most useful return value.  I think it's a
Good Thing that the return value of open() is always a valid PMC; it
can then be stored without first having to be checked for isnull.

BTW, for those of you who don't monitor RT (and why aren't you?), the
IO opcodes will not be opcodes for much longer.  They'll be library
functions.  We're hoping to bring the number of opcodes down for
various reasons that should be obvious.  But if you write PIR, you
probably won't have to change much.  And in any case the semantics of
an error return are orthogonal.

> FWIW, it also seems unfair (or at least, unobvious) that there is
> are C<isnull> and C<null> opcodes, but no corresponding codes for
> Undef or None.

"Well, don't do that, then."

You shouldn't have to check for the precise PMC type after open.
Just check for definedness.  Granted, that's two opcodes and an
integer register:

    $P0 = open "/etc/motd", "<"
    $I0 = defined $P0
    unless $I0, b0rken

But, Shirley, that's not an excessive burden.
-- 
Chip Salzenberg <[EMAIL PROTECTED]>

Reply via email to