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

Benoît Minisini g4mba5 at gmail.com
Thu Aug 22 14:28:32 CEST 2019

Le 22/08/2019 à 14:16, Bruce a écrit :
> 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"?

Property Name As String Use $name

is equivalent to:

Property Name As String
Private $name As String

Private Sub Name_Read() As String
   Return $name

Private Sub Name_Write(Value As String)
   $name = Value

Except that if you explicitly define your own Name_Read() or 
Name_Write(), it will override the one that is defined automatically by 
default (i.e. the automatic one is not generated).

It's really just a feature for lazy people. :-)

Benoît Minisini

More information about the User mailing list