Python scoping

Alex Martelli aleaxit at yahoo.com
Fri Oct 27 06:34:00 EDT 2000


"Steve Horne" <sh at ttsoftware.co.uk> wrote in message
news:gqeivsspqj64idsf6rr6dgbekif5t9osfo at 4ax.com...
> On Fri, 27 Oct 2000 00:28:15 +0200, "Alex Martelli"
> <aleaxit at yahoo.com> wrote:
>
> >I recall that in PL/I you may, if you wish, recall the label in
> >the END clause (or was it Ada...?  darn -- big languages, long
> >ago...):
>
> Ada certainly allows some types of blocks to be named, and allows you
> to use those names (for instance) to exit out of multiple layers of
> loop in one go (sound like a hidden goto?)

No, just a very useful and clear multi-level break.  Java has it
too, as, I think I recall, does Perl (Perl's keyword for it being
'last' rather than 'break').  In other languages, you have to fake
this useful control structure with exceptions and try-blocks, or
by wrapping the nested loops in a function that has no other reason
to exist (return acts as the multi-level break).  I find explicit
constructs for named-loop exit far preferable.


> You must specify the block name for 'end' with procedures and
> functions, but cannot (except comments) for ifs, loops etc.

Thanks for refreshing my fogged memory.  I now suspect PL/I was
like that, too.  Dylan, apparently, is the language that lets
you optionally name, in the END construct, what is it that you
are ending, and I think I had this vague subconscious memory
confused with the other languages that let you name blocks at
the start, but not for the purpose of naming the end as well.


Alex






More information about the Python-list mailing list