[Gambas-user] New syntactic sugar to define a property based on a global variable

Bruce adamnt42 at gmail.com
Thu Aug 22 14:16:06 CEST 2019


Good news, but just a bit of clarification please.

Consider
	Property Name as String Use $name

When you say that the syntax "automatically declares a global variable" 
do you mean that the declaration is generated into the source code in 
the IDE? Or is it declared "below the source"?

If the latter, then can that variable be accessed by other methods in 
the source?
Also, what happens in this latter case if I explicitly declare the 
variable in the source code? I'll see if I can clarify that a bit..
Lets say I have a private global $myname that I suddenly would like to 
expose as a property. $myname is used and manipulated variously 
throughout the class code. If I suddenly go:
	Property Name as String Use $myname
will this cause havoc and mayhem?

Secondly, when you say "The property methods are automatically defined 
too.", are they visible in the source code?

Finally, let's say I have a property already defined, with its' 
associated accessor methods. If I suddenly change the property 
declaration to the "Use" syntax, what would happen to the already 
defined accessors?

Just being cautious.
regards
bruce

On 22/8/19 7:35 pm, Benoît Minisini wrote:
> Hi,
> 
> I have just added the new following syntax:
> 
> PROPERTY [ READ ] PropertyName AS PropertyType USE GlobalVariableName
> 
> It declares a property and automatically declares a global variable of 
> the same type that will store the value of the property. The property 
> methods are automatically defined too.
> 
> If you explicitly define the Read or Write property method, it overrides 
> the one previously defined by default.
> 
> Regards,
> 


More information about the User mailing list