develooper Front page | perl.fwp | Postings from July 2001

Re: Sorting in-place

Thread Previous | Thread Next
From:
Abigail
Date:
July 31, 2001 14:54
Subject:
Re: Sorting in-place
Message ID:
20010731215148.13174.qmail@foad.org
On Tue, Jul 31, 2001 at 11:34:14PM +0200,  Marc A. Lehmann  wrote:
> On Tue, Jul 31, 2001 at 12:34:16PM -0700, Paul <ydbxmhc@yahoo.com> wrote:
> > >     do {{EXPR; last}}
> > > forces void context on EXPR.
> > 
> > 1) is the do{} necessary there?
> 
> Yes, because of the last. I think it's pretty unintuitive to having to
> add the above uglyness around my last statement when I know it's the last
> statement.

Well, if all you want to do is force void context on the last statement
of a sub, you don't need any of this "uglyness". The do {{EXPR; last}}
is just a general way of forcing void context on an expression - even
in the middle of some other statement.

For subs, it's trivial:

Suppose you have:

    sub foo {
        ....
        EXPR
    }

and want to force void context on EXPR. Write it as:

    sub foo {
        ....
        EXPR;
        return
    }

and you are done. No "uglyness". All you needed to do is adding an
explicite return so there are no implicite returns giving you an
unexpected context.



Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About