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

Re: expressions vs. statements

   Date: Tue, 18 Dec 2001 23:01:24 -0500
   From: Paul Prescod <paul@prescod.net>
   In Perl, you often see code like this:
   print "abc";
   print "def";
   5;  # returns 5
   That's just weird to me...the value of the last statement in a block is
   just the value of the last statement in a block.

I believe you when you say it's just weird to you.  But let's
look a little deeper.

                                                    If you want it to be
   the value of the block you should say so. ...

(a) Why?
(b) One could argue that you *do* say so: the way that you
    say what the value of a block is, is to state that value at
    the end of the block.
(c) What, did you want a "noise word"?  A noise word makes sense
    if returning a special value is the uncommon case.  Maybe in
    your style of programming or your favorite language, that is
    indeed an uncommon case.  But what if it were the common case
    (as it is in Lisp)?
(d) would you be happier if there were no semicolon after the 5?