Dr. Dobb's Python-URL! - weekly Python news and links (Nov 3)

Dave Benjamin ramen at lackingtalent.com
Mon Nov 3 14:04:39 EST 2003


In article <vqcvbu3q46o370 at news.supernews.com>, John Roth wrote:
> 
> "Dave Benjamin" <ramen at lackingtalent.com> wrote in message
> news:slrnbqcu85.u0o.ramen at lackingtalent.com...
>> In article <vqcn9ooasi2f19 at corp.supernews.com>, Emile van Sebille wrote:
>> > QOTW:  "...I want to reserve .var for the "with" statement (a la VB)."
>> >   --Guido van Rossum
>>
>> I saw this, too! Is this a joke? It seems to contradict the FAQ entry:
>>
> http://www.python.org/doc/faq/general.html#why-doesn-t-python-have-a-with-statement-like-some-other-languages
>>
>> It does seem like the .dot .prefix would disambiguate the variable scope
> as
>> long as it is used consistently, but I must say it was a surprise to read
>> this...
> 
> Aparently Guido has a number of directions he'd like to take Python,
> and some kind of *optional* typing is on the list. That's no secret,
> I've seen references to it a number of times.

Hmm! Well, if it's any indication of the future, ActionScript 2.0 (in effort
to follow JavaScript 2.0) and Perl 6 support some degree of optional typing.
As long as it doesn't feel "tacked on" or syntactically cumbersome, I'm for
it. I'd be especially interested in seeing some sort of type inference.

> Every few months, someone brings up a 'with' statement. The FAQ
> points out a number of problems with it, however, if you're willing
> to give up some dynamism and insert the needed type declarations,
> then it's not only eminently doable, but (if done right) would help
> demonstrate program correctness.

In ActionScript, there is a "with" statement, but its use is discouraged for
several reasons. First, it's confusing trying to figure out which scope
the names are coming from; even *writing* code with a "with" can be
guesswork, so reading the code isn't much better. Second, it's inefficient,
since it extends the scope chain temporarily, requiring an additional level
of indirection for any non-local variable lookup. But I think the dot-prefix
would solve this problem, since it would be unambiguous from the syntax
whether you're referring to the "with"-ed object or something else.

-- 
.:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g   l i f e   o u t   o f   t h e   c o n t a i n e r :




More information about the Python-list mailing list