[Python-Dev] Explicit Lexical Scoping (pre-PEP?)
Marek "Baczek" Baczyński
imbaczek at gmail.com
Wed Jul 5 12:17:16 CEST 2006
2006/7/5, Just van Rossum <just at letterror.com>:
> Guido van Rossum wrote:
>
> > On 7/5/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> > > Did you also consider and reject:
> > >
> > > * Alternate binding operators (e.g. ":=", ".=", etc.)
> >
> > Brr.
>
> That's too bad :(
>
> I still find a rebinding operator (":=" being my favorite) much, *much*
> more appealing than any of the alternative proposals. It's beautifully
> symmetrical with "assignment means local". It also pretty much makes the
> global statement redundant.
>
> The only downside I see is that it may cause a fairly big shift in
> style: I for one would use := for rebinding local names. While I think
> that would be an improvement (eg. by catching typo's earlier), it's
> *different*.
<delurk>
I suggest <- as an assignment operator instead of := - it's used in
OCaml and it looks *very* different, yet still makes sense.
x = 0
print x
def f():
x = 1 # bind locally
print x
def g():
x <- 42 # assign "lexically"
print x
f()
print x
g()
print x
prints
0
1
0
42
42
</delurk>
More information about the Python-Dev
mailing list