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

Christof Thalhofer chrisml at deganius.de
Thu Aug 22 15:22:15 CEST 2019


Am 22.08.19 um 14:28 schrieb Benoît Minisini:

> ----8<----
> Property Name As String Use $name
> ----8<----
> 
> is equivalent to:
> 
> ----8<----
> Property Name As String
> Private $name As String
> 
> Private Sub Name_Read() As String
>    Return $name
> End
> 
> Private Sub Name_Write(Value As String)
>    $name = Value
> End
> ----8<----
> 
> 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. :-)

Thank you for the explanation. It's also great because it makes the code
more compact and better readable.

As I always use a lot of properties, this is ultra-ultra-great! ;-)

It's just the compiler, right? If this code is compiled it can be
executed by an older interpreter? Say ... Gambas 3.9?


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190822/b2fa27ff/attachment.sig>


More information about the User mailing list