Re: some proposed changes
- From: Owen Taylor <otaylor redhat com>
- To: Huw Rogers <count0 building2 co jp>
- Cc: orbit-perl-list gnome org
- Subject: Re: some proposed changes
- Date: Thu, 2 May 2002 22:05:26 -0400 (EDT)
Huw Rogers <count0 building2 co jp> writes:
> >
> > Huw Rogers <count0 building2 co jp> writes:
> > > * if a sequence is undef, it is marshalled as a zero length sequence.
> > > Right now if it is not a true reference to an array it dies.
> >
> > I don't agree with this at all.
> >
> > $a = []; print scalar (@$a), "\n";
> > $a = undef; print scalar (@$a), "\n";
> >
> > Are very different; the second one is a warning.
> >
> > Allowing this would be similar to allowing "undef" to be marshalled as
> > an empty string without any warning, which is similar to thinking
> > in C that "" is the same as NULL. <shudder>
>
> The sequence marshalling of undef is the most dubious of my proposals,
> and I guess I should retract it.
>
> However I note that attempting to marshal undef as a string currently
> results in a core dump.
:-(. well, that's not right, of course.
> In perl, undef is a scalar, interchangeable as
> such with a string, and in CORBA "" is a null string (actual NULL is
> invalid).
The equivalence is, as I as I see it is:
C NULL ""
Perl undef ""
CORBA ---- ""
CORBA doesn't have such a thing as an NULL string, though it does have
the nil object for object references. Now, Perl has a long tradition
of coercing undefined variables to the the empty string in string
contexts:
"" . undef
gives, but it's basically there just for compatibiltiy
with Perl 4 and gives a warning when -w is used. (And
everybody uses -w when developing, I hope...)
So although I'd retract my sequence marshalling proposal, I
> would say that undef should indeed be marshalled as a null string ("")
> (which would certainly be better than the current SEGV behaviour).
Well, my opinion is it should be marshalled as a *empty* string,
but with a warning when -w is used. I believe "" and a warning is
generated if a C Perl extension calls call SvPV() on an undefined Sv.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]