Revision history for KeyPgStaticMember


Revision [21648]

Last edited on 2016-10-30 19:05:10 by fxm [Formatting]

No Differences

Revision [21143]

Edited on 2016-03-13 11:01:41 by fxm [Formatting]

No Differences

Revision [20533]

Edited on 2016-02-10 16:09:00 by DkLwikki [Update link format]
Additions:
[[KeyPgType|Type]] //typename//
**Static** //variablename// [[KeyPgAs|As]] [[DataType|DataType]] [, ...]
[[KeyPgDeclare|Declare]] **Static** [[KeyPgSub|Sub]]|[[KeyPgFunction|Function]] //procedurename// ...
[[KeyPgEndblock|End]] [[KeyPgType|Type]]
[[KeyPgDim|Dim]] //typename.variablename// [[KeyPgAs|As]] [[DataType|DataType]] [= //initializer//] [, ...]
[**Static**] [[KeyPgSub|Sub]]|[[KeyPgFunction|Function]] //typename//.//procedurename// ...
End [[KeyPgSub|Sub]]|[[KeyPgFunction|Function]]
##**Static**## methods do not have an implicit ##[[KeyPgThis|This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers). An advantage of ##**Static**## methods are that they are encapsulated in the ##//typename//## namespace, and therefore have the ability to access the ##[[KeyPgVisPrivate|Private]]## or ##[[KeyPgVisProtected|Protected]]## members or methods of instances of ##//typename//##.
##**Static**## methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type ##//typename//##, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis|This]]## (or explicit ##[[KeyPgBase|Base]]##) access possible from within a static method.
##**Static**## member variables are created and initialized only once independently of any object construction, in contrast to non-static ("instance") member variables which are created again and again for each separate object. ##**Static**## members are always ##[[KeyPgShared|Shared]]##, even if ##[[KeyPgShared|Shared]]## was not specified in the declaration. Thus, ##**Static**## member variables are similar to global variables, except that they are declared in a ##**Type**## namespace.
Each ##**Static**## member variable declared in a Type must be explicitly allocated somewhere outside the type by using a ##[[KeyPgDim|Dim]]## statement. The declaration inside the Type is the prototype that is visible to every module seeing the Type declaration. The definition outside the Type allocates and optionally initializes the ##**Static**## member variable. There can only be one definition per ##**Static**## member variable: it can only be allocated in a single module, not in multiple ones. This is the same as for ##[[KeyPgExtern|Extern]]## variables.
- ##[[KeyPgClass|Class]]##
- ##[[KeyPgDeclare|Declare]]##
- ##[[KeyPgType|Type]]##
- ##[[KeyPgStatic|Static]]##
Deletions:
[[KeyPgType Type]] //typename//
**Static** //variablename// [[KeyPgAs As]] [[DataType DataType]] [, ...]
[[KeyPgDeclare Declare]] **Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //procedurename// ...
[[KeyPgEndblock End]] [[KeyPgType Type]]
[[KeyPgDim Dim]] //typename.variablename// [[KeyPgAs As]] [[DataType DataType]] [= //initializer//] [, ...]
[**Static**] [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //typename//.//procedurename// ...
End [[KeyPgSub Sub]]|[[KeyPgFunction Function]]
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers). An advantage of ##**Static**## methods are that they are encapsulated in the ##//typename//## namespace, and therefore have the ability to access the ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members or methods of instances of ##//typename//##.
##**Static**## methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type ##//typename//##, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.
##**Static**## member variables are created and initialized only once independently of any object construction, in contrast to non-static ("instance") member variables which are created again and again for each separate object. ##**Static**## members are always ##[[KeyPgShared Shared]]##, even if ##[[KeyPgShared Shared]]## was not specified in the declaration. Thus, ##**Static**## member variables are similar to global variables, except that they are declared in a ##**Type**## namespace.
Each ##**Static**## member variable declared in a Type must be explicitly allocated somewhere outside the type by using a ##[[KeyPgDim Dim]]## statement. The declaration inside the Type is the prototype that is visible to every module seeing the Type declaration. The definition outside the Type allocates and optionally initializes the ##**Static**## member variable. There can only be one definition per ##**Static**## member variable: it can only be allocated in a single module, not in multiple ones. This is the same as for ##[[KeyPgExtern Extern]]## variables.
- ##[[KeyPgClass Class]]##
- ##[[KeyPgDeclare Declare]]##
- ##[[KeyPgType Type]]##
- ##[[KeyPgStatic Static]]##


Revision [17702]

Edited on 2015-06-21 10:21:45 by CountingPine [Some rewording]
Additions:
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers). An advantage of ##**Static**## methods are that they are encapsulated in the ##//typename//## namespace, and therefore have the ability to access the ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members or methods of instances of ##//typename//##.
For member procedures with a ##**Static**## declaration, ##**Static**## may also be specified on the corresponding procedure bodies, for improved code readability.
##**Static**## member variables are created and initialized only once independently of any object construction, in contrast to non-static ("instance") member variables which are created again and again for each separate object. ##**Static**## members are always ##[[KeyPgShared Shared]]##, even if ##[[KeyPgShared Shared]]## was not specified in the declaration. Thus, ##**Static**## member variables are similar to global variables, except that they are declared in a ##**Type**## namespace.
Deletions:
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the ##//typename//## namespace and therefore have in addition the rights to access to ##//typename//##'s ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members.
For member procedures with ##**Static**## in their prototype, ##**Static**## can also be specified on the corresponding procedure bodies, for improved code readability.
##**Static**## member variables are created and initialized only once independently of any object construction, in contrast to non-static member variables which are created again and again for each separate object. They always are ##[[KeyPgShared Shared]]##, even if ##[[KeyPgShared Shared]]## was not specified in the declaration. Thus, ##**Static**## member variables are similar to global variables, except that they are declared in a Type namespace.


Revision [17701]

Edited on 2015-06-21 04:13:01 by FxMwikki [Reworded sentence comparing static methods and normal non-member procedures]
Additions:
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the ##//typename//## namespace and therefore have in addition the rights to access to ##//typename//##'s ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members.
Deletions:
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the ##//typename//## namespace and have access to ##//typename//##'s ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members.


Revision [17051]

Edited on 2014-04-27 00:16:20 by FxMwikki [Move example for static member vars here]
Additions:
{{fbdoc item="filename" value="examples/manual/udt/static2.bas"}}%%(freebasic)
'' Assign an unique ID to every instance of a Type (ID incremented in order of creation)
Type UDT
Public:
Declare Property getID () As integer
Declare Constructor ()
Private:
Dim As Integer ID
Static As Integer countID
End Type
Dim As Integer UDT.countID = 0
Property UDT.getID () As Integer
Property = This.ID
End Property
Constructor UDT ()
This.ID = UDT.countID
UDT.countID += 1
End Constructor
Dim As UDT uFirst
Dim as UDT uSecond
Dim As UDT uThird
Print uFirst.getID
Print uSecond.getID
Print uThird.getID


Revision [17049]

Edited on 2014-04-26 12:59:48 by DkLwikki [Move static member vars here]
Additions:
**Static** //variablename// [[KeyPgAs As]] [[DataType DataType]] [, ...]
[[KeyPgDim Dim]] //typename.variablename// [[KeyPgAs As]] [[DataType DataType]] [= //initializer//] [, ...]
Deletions:
**Static** //variablename// [ (//array-dimensions//) ] [[KeyPgAs As]] [[DataType DataType]] [, ...]
[[KeyPgDim Dim]] //typename.variablename// [ (//array-dimensions//) ] [[KeyPgAs As]] [[DataType DataType]] [= //initializer//] [, ...]


Revision [17046]

Edited on 2014-04-26 12:57:46 by DkLwikki [Move static member vars here]
Additions:
Declare a static member procedure or variable
[[KeyPgDeclare Declare]] **Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //procedurename// ...
**Static** //variablename// [ (//array-dimensions//) ] [[KeyPgAs As]] [[DataType DataType]] [, ...]
[[KeyPgEndblock End]] [[KeyPgType Type]]
[[KeyPgDim Dim]] //typename.variablename// [ (//array-dimensions//) ] [[KeyPgAs As]] [[DataType DataType]] [= //initializer//] [, ...]
[**Static**] [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //typename//.//procedurename// ...
- Static member procedures
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the ##//typename//## namespace and have access to ##//typename//##'s ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members.

##**Static**## methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type ##//typename//##, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.

For member procedures with ##**Static**## in their prototype, ##**Static**## can also be specified on the corresponding procedure bodies, for improved code readability.
- Static member variables
##**Static**## member variables are created and initialized only once independently of any object construction, in contrast to non-static member variables which are created again and again for each separate object. They always are ##[[KeyPgShared Shared]]##, even if ##[[KeyPgShared Shared]]## was not specified in the declaration. Thus, ##**Static**## member variables are similar to global variables, except that they are declared in a Type namespace.

Each ##**Static**## member variable declared in a Type must be explicitly allocated somewhere outside the type by using a ##[[KeyPgDim Dim]]## statement. The declaration inside the Type is the prototype that is visible to every module seeing the Type declaration. The definition outside the Type allocates and optionally initializes the ##**Static**## member variable. There can only be one definition per ##**Static**## member variable: it can only be allocated in a single module, not in multiple ones. This is the same as for ##[[KeyPgExtern Extern]]## variables.

A ##**Static**## member variable is subject to member access control except for its definition outside the Type. If a private ##**Static**## member variable is to be explicitly initialized outside the Type's member procedures, an initializer must be provided with the definition.
Deletions:
Declare a static member procedure
[[KeyPgDeclare Declare]] **Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //procname// ...
End Type
**Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //typename//.//procname// ...
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the ##//typename//## namespace and have access to ##//typename//##'s ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members.
##**Static**## methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type ##//typename//##, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.
For member procedures with ##**Static**## in their declaration, ##**Static**## can also be specified on the corresponding procedure bodies, for improved code readability.


Revision [17045]

Edited on 2014-04-26 12:34:01 by DkLwikki [undo previous change]
Additions:
{{fbdoc item="title" value="STATIC (Member)"}}----
Deletions:
{{fbdoc item="title" value="STATIC (Member procedure)"}}----


Revision [17044]

Edited on 2014-04-26 12:31:56 by DkLwikki [member -> member procedure]
Additions:
{{fbdoc item="title" value="STATIC (Member procedure)"}}----
Deletions:
{{fbdoc item="title" value="STATIC (Member)"}}----


Revision [16675]

Edited on 2013-03-23 18:48:28 by CountingPine [Formatting, improve syntax]
Additions:
[[KeyPgDeclare Declare]] **Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //procname// ...
**Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //typename//.//procname// ...
##**Static**## methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type ##//typename//##, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.
Deletions:
[[KeyPgDeclare Declare]] **Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] ...
**Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //typename// ...
##**Static**## methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.


Revision [16670]

Edited on 2013-03-23 08:38:02 by FxMwikki [Formatting]
Additions:
##**Static**## methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.
Deletions:
Static methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.


Revision [16659]

Edited on 2013-03-22 11:29:39 by CountingPine [Formatting]
Additions:
##**Static**## methods do not have an implicit ##[[KeyPgThis This]]## instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the ##//typename//## namespace and have access to ##//typename//##'s ##[[KeyPgVisPrivate Private]]## or ##[[KeyPgVisProtected Protected]]## members.
Static methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit ##[[KeyPgThis This]]## (or explicit ##[[KeyPgBase Base]]##) access possible from within a static method.
Deletions:
##**Static**## methods do not have an implicit [[KeyPgThis This]] instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the //typename// namespace and have access to //typename//'s [[KeyPgVisPrivate Private]] or [[KeyPgVisProtected Protected]] members.
Static methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit [[KeyPgThis This]] (or explicit [[KeyPgBase Base]]) access possible from within a static method.


Revision [16497]

Edited on 2012-12-22 07:58:14 by FxMwikki [As 'This.', 'Base.' is also forbidden inside a static member procedure body]
Additions:
Static methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit [[KeyPgThis This]] (or explicit [[KeyPgBase Base]]) access possible from within a static method.
Deletions:
Static methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit [[KeyPgThis This]] access possible from within a static method.


Revision [16440]

Edited on 2012-11-16 08:54:44 by DkLwikki [fix Private/Protected links]
Additions:
##**Static**## methods do not have an implicit [[KeyPgThis This]] instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the //typename// namespace and have access to //typename//'s [[KeyPgVisPrivate Private]] or [[KeyPgVisProtected Protected]] members.
Deletions:
##**Static**## methods do not have an implicit [[KeyPgThis This]] instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the //typename// namespace and have access to //typename//'s [[KeyPgPrivate Private]] or [[KeyPgProtected Protected]] members.


Revision [16437]

Edited on 2012-11-16 08:51:36 by DkLwikki [simpler syntax, rewrite description]
Additions:
Declare a static member procedure
Deletions:
Declaration specifier for a static member procedure.


Revision [16435]

Edited on 2012-11-16 08:51:17 by DkLwikki [simpler syntax, rewrite description]
Additions:
[[KeyPgDeclare Declare]] **Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] ...

**Static** [[KeyPgSub Sub]]|[[KeyPgFunction Function]] //typename// ...
...
End [[KeyPgSub Sub]]|[[KeyPgFunction Function]]
##**Static**## methods do not have an implicit [[KeyPgThis This]] instance argument passed to them. This allows them to be used like normal non-member procedures (for example with callback procedure pointers), the only difference being that they are encapsulated in the //typename// namespace and have access to //typename//'s [[KeyPgPrivate Private]] or [[KeyPgProtected Protected]] members.

Static methods can be called directly anywhere in code, like normal non-member procedures, or on objects of type //typename//, similar to non-static methods, however either way there is no implicit or explicit [[KeyPgThis This]] access possible from within a static method.

For member procedures with ##**Static**## in their declaration, ##**Static**## can also be specified on the corresponding procedure bodies, for improved code readability.
Deletions:
[[KeyPgDeclare declare]] **Static** //membertype// //membername// ...
{{fbdoc item="param"}}
##//typename//##
name of a user defined data type
##//membertype//##
##[[KeyPgMemberSub Sub]]## or ##[[KeyPgMemberFunction Function]]##.
##//membername// ...##
Name of the member to declare or define with parameter list or return value following.
When declaring a member procedure, ##**Static**## specifies that the member procedure not have an implicit instance argument passed to it, and thus can only access values passed to it. Static member procedures may access Private or Protected members in their type, but to call procedures you must pass the Object as an additional first parameter. You may call a static member procedure anywhere in your code just like any other procedure in a type, i.e. //variable of the type//.//static procedure name//(//arguments//). The address of a static member function can also be assigned to a function pointer using the standard [[KeyPgOpProcptr ProcPtr()]] or the [[KeyPgOpAt @ Operator]] usage.
##**Static**## is allowed in front of member procedure bodies, not just in the declaration (the coherence with declaration is checked by compiler). When the procedure body is far from the declaration, it may be suitable to have here the information.


Revision [16333]

Edited on 2012-09-08 15:24:17 by FxMwikki [In example, typename "Object" is changed to "_Object"]
Additions:
type _Object
declare static sub handler_default( byref obj as _Object )
declare static sub handler_A( byref obj as _Object )
declare static sub handler_B( byref obj as _Object )
handler_func as sub( byref obj as _Object )
constructor _Object( byval ht as handlertype )
handler_func = @_Object.handler_A
handler_func = @_Object.handler_B
handler_func = @_Object.handler_default
sub _Object.handler()
sub _Object.handler_default( byref obj as _Object )
sub _Object.handler_A( byref obj as _Object )
sub _Object.handler_B( byref obj as _Object )
dim objects(1 to 4) as _Object => _
_Object.handlertype.ht_B, _
_Object.handlertype.ht_default, _
_Object.handlertype.ht_A _
'' 4th array item will be _Object.handlertype.ht_default
Deletions:
type Object
declare static sub handler_default( byref obj as Object )
declare static sub handler_A( byref obj as Object )
declare static sub handler_B( byref obj as Object )
handler_func as sub( byref obj as Object )
constructor Object( byval ht as handlertype )
handler_func = @Object.handler_A
handler_func = @Object.handler_B
handler_func = @Object.handler_default
sub Object.handler()
sub Object.handler_default( byref obj as Object )
sub Object.handler_A( byref obj as Object )
sub Object.handler_B( byref obj as Object )
dim objects(1 to 4) as Object => _
Object.handlertype.ht_B, _
Object.handlertype.ht_default, _
Object.handlertype.ht_A _
'' 4th array item will be Object.handlertype.ht_default


Revision [16195]

Edited on 2012-05-30 11:55:16 by FxMwikki [Static is allowed in front of member procedure bodies, not just in the declaration]
Additions:
##**Static**## is allowed in front of member procedure bodies, not just in the declaration (the coherence with declaration is checked by compiler). When the procedure body is far from the declaration, it may be suitable to have here the information.


Revision [14446]

Edited on 2009-08-29 21:57:08 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [10985]

The oldest known version of this page was created on 2007-09-03 16:11:15 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode