[Gambas-user] Correct strategy for VB static var conversion to Gambas?

Christof Thalhofer chrisml at deganius.de
Sun May 30 20:43:00 CEST 2021



Am 30.05.21 um 18:55 schrieb John Anderson:
> On 5/29/2021 3:50 PM, Christof Thalhofer wrote:
>> Am 29.05.21 um 22:09 schrieb Benoît Minisini:
>>
>>> So maybe I could allow declaring "static variables" (actually private
>>> global class variables) inside functions in the future.
>> That would make code even uglier. Is there any reason to do this that
>> makes sense?
>>
>> Alles Gute
>>
>> Christof Thalhofer
>>
> 
> Thanks, I understand your concern...and it is not my intention that my
> needs require Gamabs to break anything it currently does well.
> 
> Let me explain the situation more.  Warning - this is long, but only way
> I know of to explain.  If your time is short please just skip the rest.
> The following ONLY applies to VB conversion project.
> 
> Well, in order to implement the equivalent of a "Static" var in a
> function, and since a lot of our functions use common names as
> "mystaticvar" in lots of functions: the only way I know of is to make a
> separate module for each function.
Ok, now I think I understand. Maybe it was a misunderstanding by me, I
thought you wanted to be able to define *Global* Static Variables inside
functions (I mean global accessible). I think I did not read carefully
enough.

As I now understand you want to have variables that reside inside
methods that keep their value from call to call.

This undermines what I think is an important security aspect of Gambas,
which is that methods in classes are stateless unless they use global
variables of the class. Programmers who are not that experienced might
be misled by the name "static". Readers of code could easily overread
that a variable is not stateless any more.

Gambas actually has a pretty clean design, I'm unsure if it will be
compromised by this idea. I'm afraid it will be.

There is an agreement that Gambas programmers use the prefix "$" for
variable names to indicate a global variable of a class. Actually, if
your idea were implemented, one would have to consider that static
variables within methods get their own prefix to identify them and a
common agreement to use that.

I did not read your long mail to the end, maybe there will be more
arguments from my side.

Alles Gute

Christof Thalhofer

-- 
[x] nail here for new monitor


More information about the User mailing list