Title: Language Modernization ideas for discussion - Idea 5 - Private Globals Post by: Eric B. on January 25, 2021, 11:57:47 pm Next idea: "Private Globals". This is a ripoff of the concept of static variables in other languages. Although it doesn't really add new functionality, I think it would considerably improve organization and readability of code. Basically this implements a private function variable that retains it's value globally/after the function exists. This could be use for factory functions and similar. I'd think something like "GLOBAL DEFINE x" to declare it.
For instance, you'd have: Code
The main benefit here is that the variable and its usage are kept together if it is managed by a single function. As such it's more of a readability assist; the behavior would be no different from declaring a module-level private variable with the added protection that the compiler would prevent multiple functions in the same module from manipulating the variable. Title: Re: Language Modernization ideas for discussion - Idea 5 - Private Globals Post by: Sebastien F. on January 28, 2021, 12:05:35 pm Hello,
The idea is clear, thanks for the suggestions. I have filed this request as FGL-5524 (not visible in the issue tracker for now) Will be discussed internally, having a ticket does not mean it will be done. I would not use the concept "GLOBAL" because this is well know for global variables visible to all functions. Seb Title: Re: Language Modernization ideas for discussion - Idea 5 - Private Globals Post by: Rene S. on January 28, 2021, 02:22:01 pm Hello colleagues:
you're not asking for "private globals", you're asking for (C-speaking) static local variables (or none auto local variables). I would not name this "language modernization". Modern languages like Java or Google-Go don't know none auto local variables. I don't see any reason for supporting this request in Genero-4GL. There really no added value. Rene |