[Gambas-user] variable declaration everywhere ???
David Sanromá
dsanroma at gmail.com
Wed Dec 12 00:39:39 CET 2018
El 12/12/18 a las 0:16, Benoît Minisini escribió:
> Le 12/12/2018 à 00:11, Jussi Lahtinen a écrit :
>> Why would it be harder to debug?
>> David gave great example of it usage (pretty much only case where I
>> use it) and I think it only makes code more readable and less scope
>> for the variable.
>>
>>
>> Jussi
>>
>
> Because as soon as variables can be declared anywhere, people will
> start to use that for writing ugly code. :-)
>
Why not a compromise ?
Dim i as Integer -> anywhere = illegal (just like now)
However cases like:
For i As Integer = 1 To 10
For Each aString as String in stringArray
Could be considered legal. That way we could have both worlds.
Variables could "only" be declared with a Dim in the declaration area.
---> Clean Code (like now)
Control loop variables "could" be defined in place ---> Practical and
also clean code.
Just an idea....
David
More information about the User
mailing list