[Gambas-user] sign $

Tobias Boege taboege at gmail.com
Sun Jun 10 18:20:12 CEST 2018


On Sun, 10 Jun 2018, Mayost Sharon wrote:
> Hello to you
> 
> I wanted to know
> When I declare variables I sometimes see:
> $ Sign
> And sometimes not
> 
> For example, I took part of a section of gb.setting
> 
> Export
> Create Static
> 
> Class Window
> Class Desktop
> Class DesktopWindow
> Class Screens
> 
> Static Property Read DefaultDir As String
> 
> Static Private $ sStr As String
> Static Private $ iPos As Integer
> 
> Property Read Keys As _Settings_Keys
> Property Read Path As String
> 
> Private $ sPath As String
> Private $ sTitle As String
> Private $ cSlot As Collection
> Private $ bModify As Boolean
> Private $ bModifyAll As Boolean
> Private $ cModify As Collection
> 

This is a naming convention in the Gambas source tree. Private variables
start with a dollar sign [1]. Other than being conventional, there is no
meaning to that.

> And I see that there are functions with a $ sign
> 
> For example:
> Format $
> or
> Format without a $ sign
> 

The dollar sign is a suffix here and the meaning is completely different.
I believe it is inherited from earlier BASIC languages and it hints at
the function operating on a string. All functions which have the $-suffix
also have a name without that suffix: Format$ <-> Format, Mid$ <-> Mid,
Hex$ <-> Hex and so on. Both names map to exactly the same opcode, there
is no difference and no meaning to that suffix.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/doc/naming

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list