[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] FNG



At 17.10 -0500 1999.01.27, Geoffrey C Kinnel wrote:
>There are two kinds of null, defined and undefined.

OK.

>Null does not
>necessarily mean undef.

OK.

>A null scalar in a integer context is 0, a null
>scalar in a string context is ''.

Depends on what you mean.  Where one operator changes depending on what the
scalar is, then this is not necessarily the case.  int() is clearly numeric
context.  ~ is not.


>In $x you have an undefined value. In
>$w you have an defined value, null. In the print statement, you are
>forcing $w to a string context, where it gets evaluated and printed as a
>null *string*. Try using %d and see what happens.

Using %d would not have made a difference in my last example.  You seem to
be asserting that forcing a defined null into numeric context yields 0.
That has never been in question.  I was demonstrating that there is a
distinct difference between the defined nulls in these three statements:

  $x = '';
  $y = 0;
  $z = /a/;

First, you have something that is a null string.  Then you have something
that is a null number.  Then you have something that sometimes acts like a
null string, and sometimes like a null number, even when the context is
ambiguous.  "print $z" will treat $z as a null string.  "~$z" will treat $z
as a null number.

Ronald notes that something called SV_NO provides both values to the
scalar.  So now it begs the question:  does ~ assume numeric context first
if there is an integer value available, and if the string value was not the
last one to be used?  Is this a characteristic of ~, or of perl, which
returns the numeric value if neither one has ever been used?  If it is a
characteristic of perl, why does "print $z" treat it as a string?

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch