[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl5-porters
Subject:    Re: A plea for Or-Defined: ordef, |||, |||=
From:       William R Ward <hermit () BayView ! COM>
Date:       1999-10-29 9:00:19
[Download RAW message or body]

"Mark Mielke" <markm@nortelnetworks.com> writes:
>      my $a   : string;
> 
>      $a ||= $b;  # Just works "right"

I have trouble understanding how this would work - strings can still
be false if they are "0" or "".

Anyway, I've been not following p5p closely and lately I have started
poking my nose in again.  I notice examples like you are giving above
with a "my $a : string" or "our $FOO : export" being bandied about,
and I'm not clear on what the new ": keyword" thing is supposed to be.

However, would this work?

   my $a : default(shift, 42);

The meaning of this would be the same as this:

   my $a = shift;
   $a = 42 unless defined $a;

One could give a list of values in the list after ": defined", and the
first non-undef one would be assigned to $a.

--Bill.

-- 
William R Ward        hermit@bayview.com      http://www.bayview.com/~hermit/
-----------------------------------------------------------------------------
The secret of being creative is making something that's not very new
but just a little bit different in the right direction - Marvin Minsky

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic