Python scoping

Quinn Dunkan quinn at cruzeiro.ugcs.caltech.edu
Mon Nov 6 04:38:18 CET 2000


On Wed, 1 Nov 2000 23:09:12 GMT, Garry Hodgson <garry at sage.att.com> wrote:
>Michael Ackerman wrote:
>> 
>> "Steven D. Majewski" wrote:
>> >
>> > On Tue, 24 Oct 2000, Joshua Muskovitz wrote:
>> >
>> .
>> >  A situation where the human eye uses indentation and the compiler
>> > uses braces is unsafe.
>> 
>> Why is it unsafe? Doesn't it work well in Haskell?
>
>haskell uses indentation, like python.

But the compiler uses braces.  Think about it the next time hugs gives you an
"unexpected }" error when you haven't written any braces.  Aside from a few
non-obvious error msgs, I haven't found it to be unsafe.  No one's been hurt,
gotten pregnant, or been tagged out by it.  So I don't put a lot of stock in
the original poster's unsupported vague assertion :)

Of course, there are a few oddities with the combination of do-notation sugar
mixed with offside rule sugar... having multiple layers of syntax rewriting
going on *does* seem confusing and too complicated to me.  E.g.

do
    x <- foo
    if baz then bar else ...

is no good, but

do {
    x <- foo;
    if baz then bar else ...
}

works, as does

foo >>= \x -> if baz then bar else...

But I'm sure if I spend a little time with the Report it'll come clear :)

And anyway, I'm glad python is not so sugar-happy.



More information about the Python-list mailing list