With or Using
Carlos Ribeiro
cribeiro at mail.inet.com.br
Thu Apr 19 23:59:35 EDT 2001
At 16:11 18/04/01 +0000, David C. Ullrich wrote:
>It's in Delphi all right. Now find five Delphi experts and ask them
>whether they think it's a good idea.
I dont know if the expression "Delphi expert" applies to myself; however, I
did happen to be a beta tester of Delphi 1 (when it was distributed in
floppies :-). In Delphi, "with" is a good idea, but not so in Python. Why
it is different? Because both languages have different type models.
Delphi uses static types. So it is possible to know, in a unambiguous way,
what member is being assigned in a "with" clause. This is important for
both the compiler *and* the programmer. In fact, some Delphi experts may
argue that the "with" construct should be avoided. I believe it is a matter
of personal taste, because a careful read will always reveal wich variable
(or member of) is getting assigned.
Python uses dynamic types. It is impossible to know in advance which
attribute will be referenced at runtime. Member attributes may be added or
removed from objects on the fly. This would make it impossible to know,
from a simple reading, what attribute is being read - a local one, a global
one, or a member attribute.
The same argument also applies to the use of self, that is mandatory on
Python, but not on Delphi. In Delphi all you have is a implicit "with"
clause on self on the beginning of every method implementation.
Carlos Ribeiro
More information about the Python-list
mailing list