Adding optional 'explicit' declaration?
Laurent Pointal
laurent.pointal at wanadoo.fr
Thu Apr 26 15:39:02 EDT 2001
scarblac at pino.selwerd.nl (Remco Gerlich) wrote in
<slrn9eg5uc.34r.scarblac at pino.selwerd.nl>:
>Laurent Pointal <pointal at lure.u-psud.fr> wrote in comp.lang.python:
>> The idea is to optionnaly allow to force an explicit variable
>> declaration in Python functions/methods for compilation time check.
>>
>> The transparent creation of variables in Python is really nice, but
>> there are times when it become a bug source, essentially because of
>> misstyping of variable names.
>
>Does anyone have any numbers on this? People make this claim all the
>time, but in practice my typos are always caught at compile time or
>immediate testing already. I believe bugs like this are really rare.
Using Python since few years (AFAIR 1998), I encouter it enough time to
consider it as a problem. I made that post after encoutering again such a
bug with a coworker which start with Python (1/2 day to found... it was in a
function which was so simple that it may give into no problem... and
exceptions catching hide the traceback).
>>Does anyone have numbers from a real project on how many bugs were
>caused by typos like this? What percentage of all bugs was that?
Sorry, I dont use a bug tracking system.
>This looks to me like a feature request based on FUD that we're arguing
>against with FUD, some facts would be nice...
Experience... not FUD.
>> What do you think of this?
>
>The types-sig is a whole special interest group about this topic.
>
>I think that there are many cases in which you can't do the checks at
>compile time anyway (libraries that aren't strictly typed, eval()), and
>even more cases in which type checking would be bad (passing a UserList
>instead of a list). But that's mostly opinion, as I said, facts would be
>nice.
I dont wants to add **type** checking, but only variables typping mistake.
>And similar to Alex's excellent rant, I hope people aren't trying to
>make Python the one language to use for everything...
This is not a try to add a big feature, but a tool which - I think - may be
not so hard to add to compiler, and can avoid typping mistakes.
Even [please avoid long discussions on it - I dont like it too] Visual Basic
has added such a control (optional too).
A+
Laurent.
More information about the Python-list
mailing list