[Gambas-user] variable declaration everywhere ???

Benoît Minisini g4mba5 at gmail.com
Fri Dec 14 00:51:30 CET 2018


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


More information about the User mailing list