why ; ?
Michael Neumann
mneumann at ntecs.de
Fri May 9 15:52:26 PDT 2008
Don wrote:
> Yes, but when you have declarations, you can reduce that probability
> dramatically by using meaningful identifier names. That doesn't work in
> a language without them.
>
> HaveWeInitializedEverythingYet when elsewhere it is
> HaveWeInitialisedEverythingYet
>
> (I've had examples like that in PHP).
Not neccessarily! The last 45 minutes I hacked up TypoCheck, which
inspects the source code of any Ruby application and will warn about any
potential mispelled local variable. I use the Levensthein distance for
that.
http://www.ntecs.de/projects/TypoCheck/
This will catch most cases, except very short variable names, as here
it's hard to distinguish a typo.
Of course it can never be as good as when manually declaring variables
(due to missing redundance).
>> bugs(no variable initialization) > 100 * bugs(dangling pointers).
>
> Yes, I probably overstated the case for declarations. But my experience
> with PHP is that absence of declarations is the number 1 source of bugs
> in that language. And it manifests itself as an initialization problem
> -- I DID initialise that variable, but because of a typo, I find that
> it's unexpectedly zero!
So I guess PHP will just return a value if you read an uninitialized
local variable, while Ruby will very likely raise an exception.
Uhm, but I think it's getting very off-topic :)
Regards,
Michael
More information about the Digitalmars-d
mailing list