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

Re: [MacPerl] Does Style Count? (formally, 'file tests')



On Thu, 29 Oct 1998 20:45:55 -0800 (PST), Xah Lee wrote:

>In practice, this means one can do:
>
>my $var = (predicate ? expr1: expr2);
>
>but not
>
>my $var = if (predicate) {expr1} else {expr2};

Don't forget about:

 my $var = do { if (predicate) { expr1 } else { expr2 } };


I know TIMTOWTDI, but this is ridiculous. It clearly shows the history
of the language (incl. it's C inheritance); not all syntax rules were
introduced at the same time. The last version looks like it's been
borrowed from LISP.

In case you'd doubt if this really works, here's some real code:

    #! perl
    for $i (0..1) {
        my $var = do { if ($i) { 'true' } else { 'false' } };
        print "i = $i, $var\n";
    }

Result:

  i = 0, false
  i = 1, true

	Bart.

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