[Gambas-user] variable declaration everywhere ???
bagonergi at gmail.com
Fri Dec 14 12:38:33 CET 2018
Il giorno ven 14 dic 2018 alle ore 00:52 Benoît Minisini <g4mba5 at gmail.com>
> Le 14/12/2018 à 00:02, Christof Thalhofer a écrit :
> > Am 12.12.18 um 00:16 schrieb Benoît Minisini:
> >> Because as soon as variables can be declared anywhere, people will start
> >> to use that for writing ugly code. :-)
> > Exactly. I know it because I had a hard work with my own code which was
> > more than ten years old (VBA).
> > If we have to declare variables only at the beginning we tend to write
> > shorter methods which is much easier to understand. Especially if the
> > code is a couple of weeks/months/years old.
> > Since I program in Gambas my methods are smaller. Every time I see that
> > I had to declare many variables at the beginning I feel a kind of shame.
> > Because I know that the number of variables correlates with the
> > incomprehensibility of my own code.
> > Alles Gute
> > Christof Thalhofer
> Since last commit:
> - Local variables can be declared anywhere in the function, but they
> always have a function scope.
> - Loop variables can be declared directly in the loop opening syntax.
> And they too have a function scope.
> - Loop variables can be redeclared as soon as it keeps its type.
> Now maybe I could start thinking releasing Gambas 3.12?
> Or should I remove the possibility of declaring variables anywhere before?
> Benoît Minisini
Public Sub Main()
For n As Byte = 0 To 9
Dim v As Byte
Dim sStr As String = Split("Any phrase of this book", " ")
For Each s As String In sStr
If sStr Then Print "sStr exist"
Would not it be more logical to expect that only sStr existed after the For
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User