[Gambas-user] variable declaration everywhere ???
Gianluigi
bagonergi at gmail.com
Wed Dec 12 09:32:38 CET 2018
Il giorno mer 12 dic 2018 alle ore 00:42 David Sanromá <dsanroma at gmail.com>
ha scritto:
>
> 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
>
When yesterday we discussed on the Italian forum, in addition to what I
said here, I also said that the only place where this innovation could be
useful were the loops.
I see no other possible advantage but I only see the disadvantage of
chaotic code.
If someone wants to declare variables "on the fly" he can very well use the
Editor's split
Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181212/e6409550/attachment.html>
More information about the User
mailing list