[Python-Dev] Re: PEP 340 - possible new name for block-statement

2005-04-29 Thread Reinhold Birkenfeld
Guido van Rossum wrote:

>> Another possibility just occurred to me. How about "using"?
> 
> Blah. I'm beginning to like block just fine. With using, the choice of
> word for the generator name becomes iffy IMO; and it almost sounds
> like it's a simple renaming: "using X as Y" could mean "Y = X".

FWIW, the first association when seeing

block something:

is with the verb "to block", and not with the noun, which is most displeasing.

Reinhold

-- 
Mail address is perfectly valid!

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Re: PEP 340 - possible new name for block-statement

2005-04-29 Thread Nicolas Fleury
Guido van Rossum wrote:
[Nicolas Fleury]
scoped EXPR as VAR:
BLOCK
Definitely not. In too many languages, a "scope" is a new namespace,
and that's exactly what a block (by whichever name) is *not*.
Humm... what about "context"?
context EXPR as VAR:
BLOCK
I may answer the question myself, but is an alternative syntax without 
an indentation conceivable? (yes, even since the implicit block could be 
run multiple times).  Because in that case, a keyword like "block" would 
not look right.

It seems to me that in most RAII cases, the block could end at the end 
of the current block and that's fine, and over-indentation can be 
avoided.  However, I realize that the indentation makes more sense in 
the context of Python and removes some magic that would be natural for a 
C++ programmer used to presence of stack...  Ok, I answer my question, 
but "context" still sounds nicer to me than "block";)

Regards,
Nicolas
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Re: PEP 340 - possible new name for block-statement

2005-04-29 Thread André Roberge
Robin Munn wrote:
[snip]
Another possibility just occurred to me. How about "using"?
~using EXPR as VAR:
~BLOCK
Examples from PEP 340:
==
def synchronized(lock):
...
using synchronized(myLock):
...
= (+0)
def opening(filename, mode="r"):
...
using opening("/etc/passwd") as f:
...
= (+1)
def auto_retry(n=3, exc=Exception):
...
using auto_retry(3, IOError):
...
= (+1)
def synchronized_opening(lock, filename, mode="r"):
...
using synchronized_opening("/etc/passwd", myLock) as f:
...
= (+1)
A.R.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Re: PEP 340 - possible new name for block-statement

2005-04-29 Thread Josiah Carlson

Guido van Rossum <[EMAIL PROTECTED]> wrote:
> 
> [Nicolas Fleury]
> > I would prefer something that would be
> > understandable for a newbie's eyes, even if it fits more with common
> > usage than with the real semantics behind it.  For example a Boost-like
> > keyword like:
> > 
> > scoped EXPR as VAR:
> >  BLOCK
> 
> Definitely not. In too many languages, a "scope" is a new namespace,
> and that's exactly what a block (by whichever name) is *not*.

scopeless, unscoped, Scope(tm) (we would be required to use the unicode
trademark symbol, of course)...

It's way too long, and is too close to a pre-existing keyword, but I
think 'finalized' is descriptive.  But...

finalize EXPR as VAR:
BLOCK

That reads nice...  Maybe even 'cleanup', or
'finalize_after_iteration_without_iter_call' (abbreviated to 'faiwic',
of course). <1.0 wink>

All right, it's late enough.  Enough 'ideas' from me tonight.

 - Josiah

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Re: PEP 340 - possible new name for block-statement

2005-04-28 Thread Guido van Rossum
[Nicolas Fleury]
> I would prefer something that would be
> understandable for a newbie's eyes, even if it fits more with common
> usage than with the real semantics behind it.  For example a Boost-like
> keyword like:
> 
> scoped EXPR as VAR:
>  BLOCK

Definitely not. In too many languages, a "scope" is a new namespace,
and that's exactly what a block (by whichever name) is *not*.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Re: PEP 340 - possible new name for block-statement

2005-04-28 Thread Nicolas Fleury
Guido van Rossum wrote:
A variation on this with somewhat different semantics swaps the keywords:
in EXPR for VAR:
BLOCK
If you don't need the variable, you can leave the "for VAR" part out:
in EXPR:
BLOCK
Too cute? :-)
I don't think it reads well.  I would prefer something that would be 
understandable for a newbie's eyes, even if it fits more with common 
usage than with the real semantics behind it.  For example a Boost-like 
keyword like:

scoped EXPR as VAR:
BLOCK
scoped EXPR:
BLOCK
We may argue that it doesn't mean a lot, but at least if a newbie sees 
the following code, he would easily guess what it does:

scoped synchronized(mutex):
scoped opening(filename) as file:
...
When compared with:
in synchronized(mutex):
in opening(filename) for file:
...
As a C++ programmer, I still dream I could also do:
scoped synchronized(mutex)
scoped opening(filename) as file
...
which would define a block until the end of the current block...
Regards,
Nicolas
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com