develooper Front page | perl.perl6.language | Postings from February 2001

Re: assign to magic name-of-function variable instead of "return"

Thread Previous | Thread Next
From:
John Porter
Date:
February 5, 2001 10:37
Subject:
Re: assign to magic name-of-function variable instead of "return"
Message ID:
20010205133700.B12785@min.net
Damian Conway wrote:
> 
> Actually, I do agree that Perl 6 ought to provide a universal "destructor"
> mechanism on *any* block. For historical reasons, I suppose it should be
> C<continue>, though I would much prefer a more generic name, such as
> C<cleanup>.

But in some sense it's much more like the file-level END block.
It should have visibility to the lexicals in the block to which
it applies.  That's why, as I advocated wrt catch blocks in,
for example,
  http://archive.develooper.com/perl6-language@perl.org/msg02294.html
that the "handler" block should be nested within the block to
which it pertains, in much the same way that BEGIN and END blocks
reside inside the file to which they pertain.

So:

	sub readit {
		open F, "< $f" or die "$f: $!";
		<F>;

		catch { ... }
		end { close F }
	}

-- 
John Porter

You can't keep Perl6 Perl5.


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