Revision history for KeyPgUnion


Revision [22066]

Last edited on 2017-12-31 04:04:07 by fxm [Added precision in Note]
Additions:
**Note:** When ##**Union**## extends a base, it can be confusing because no new fields are added to the base, but instead the base is added to the derived Union. This means that fields in the derived Union can share the same memory space like the base (here it doesn't matter whether the base is a Union or not). Of course it can be dangerous, but that is always the problem with Unions.
If only the base is a Union, then it won't be affected by fields from the derived UDT.
Since Union is not allowed to have complex fields (i.e. UDTs with constructor/destructor, or dynamic strings), a derived Union cannot be allowed to have (contain) a complex base.
Deletions:
**Note:** When ##**Union**## extends a base, it can be confusing because no new fields are added to the base, but instead the base is added to the derived Union. This means that fields in the derived Union can share the same memory space like the base. Of course it can be dangerous, but that is always the problem with Unions.


Revision [22044]

Edited on 2017-12-20 16:17:12 by fxm [Added note on inheritance]
Additions:
**Note:** When ##**Union**## extends a base, it can be confusing because no new fields are added to the base, but instead the base is added to the derived Union. This means that fields in the derived Union can share the same memory space like the base. Of course it can be dangerous, but that is always the problem with Unions.


Revision [22043]

Edited on 2017-12-20 15:49:09 by fxm [Added precision on inheritance from a base]
Additions:
Unlike Type, Union can not contain variable-length strings, and more generally fields (or can not have bases) with constructors or destructors. Therefore, Union does not support to inherit from the ##[[KeyPgObject|Object]]## built-in type.
Deletions:
Unlike Type, Union can not contain variable-length strings, and more generally fields (or can not have bases) with constructors or destructors.


Revision [21368]

Edited on 2016-04-15 08:12:43 by fxm [Added link to 'Coercion and Conversion']
Additions:
- [[ProPgDataConversion|Coercion and Conversion]]


Revision [21167]

Edited on 2016-03-13 11:32:30 by fxm [Formatting]
Additions:




Revision [20571]

Edited on 2016-02-10 16:10:04 by DkLwikki [Update link format]
Additions:
//fieldname// as [[DataType|datatype]]
[[KeyPgDeclare|declare]] //member function declaration// ...
Unions are similar to a ##[[KeyPgType|Type]]## structure, except that the elements of a union occupy the same space in memory.
Like Type, Union can use the optional ##[[KeyPgField|Field]] = //number//## specifier and supports also inheritance through the use of the [[KeyPgExtends|Extends]] keyword.
The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType|Type]]##. Since they occupy the same space, only a single element can be used.
Unions support member functions including ##[[KeyPgConstructor|Constructor]]##, ##[[KeyPgDestructor|Destructor]]##, ##[[KeyPgMemberFunction|Function]]##, ##[[KeyPgOperator|Operator]]##, ##[[KeyPgProperty|Property]]## and ##[[KeyPgMemberSub|Sub]]##. All members of a union are public and access control is not supported.
au as ubyte
bu as integer
- Object-related features as functions defined inside the ##**Union**## block are supported only in the //[[CompilerOptlang|-lang fb]]// dialect.
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Union""**##.
- ##[[KeyPgType|Type]]##
Deletions:
//fieldname// as [[DataType datatype]]
[[KeyPgDeclare declare]] //member function declaration// ...
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory.
Like Type, Union can use the optional ##[[KeyPgField Field]] = //number//## specifier and supports also inheritance through the use of the [[KeyPgExtends Extends]] keyword.
The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.
Unions support member functions including ##[[KeyPgConstructor Constructor]]##, ##[[KeyPgDestructor Destructor]]##, ##[[KeyPgMemberFunction Function]]##, ##[[KeyPgOperator Operator]]##, ##[[KeyPgProperty Property]]## and ##[[KeyPgMemberSub Sub]]##. All members of a union are public and access control is not supported.
au as ubyte
bu as integer
- Object-related features as functions defined inside the ##**Union**## block are supported only in the //[[CompilerOptlang -lang fb]]// dialect.
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Union""**##.
- ##[[KeyPgType Type]]##


Revision [17368]

Edited on 2014-11-05 03:38:49 by FxMwikki [Local union cannot have procedures members or static data members.]
Additions:
Nested unnamed type or union cannot have procedure members or static data members (same restriction for local named type/union).
Deletions:
Nested unnamed type or union cannot have function members or static data members.


Revision [16997]

Edited on 2014-01-17 03:28:01 by FxMwikki [Added detail and formating]
Additions:
Like Type, Union can use the optional ##[[KeyPgField Field]] = //number//## specifier and supports also inheritance through the use of the [[KeyPgExtends Extends]] keyword.


Revision [16995]

Edited on 2014-01-16 16:22:40 by FxMwikki [Added detail and formating]
Additions:
Unlike Type, Union can not contain variable-length strings, and more generally fields (or can not have bases) with constructors or destructors.
Deletions:
Unlike Type, Union can not contain variable-length strings, and more generally fields or bases with constructors or destructors.


Revision [16994]

Edited on 2014-01-16 13:13:15 by FxMwikki [Added detail and formating]
Additions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory.
Unlike Type, Union can not contain variable-length strings, and more generally fields or bases with constructors or destructors.
The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.
Deletions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (but unlike Type, Union can not contain variable-length strings, and more generally fields with constructors or destructors). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.


Revision [16946]

Edited on 2013-09-13 05:42:00 by FxMwikki [Nested unnamed type or union also cannot have static data members]
Additions:
Nested unnamed type or union cannot have function members or static data members.
Deletions:
Unnamed type nested inside a named union cannot have function members.


Revision [16810]

Edited on 2013-05-19 13:50:16 by FxMwikki [Nested unnamed type cannot have function members]
Additions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (but unlike Type, Union can not contain variable-length strings, and more generally fields with constructors or destructors). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.
Unions support member functions including ##[[KeyPgConstructor Constructor]]##, ##[[KeyPgDestructor Destructor]]##, ##[[KeyPgMemberFunction Function]]##, ##[[KeyPgOperator Operator]]##, ##[[KeyPgProperty Property]]## and ##[[KeyPgMemberSub Sub]]##. All members of a union are public and access control is not supported.
Unnamed type nested inside a named union cannot have function members.
Deletions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (but unlike Type, Union can not contain variable-length strings, and more generally fields with constructors or destructors). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.
Unnamed unions can be nested inside a type structure and unnamed types can be nested inside an union. See Example.
Unions support member functions including ##[[KeyPgConstructor Constructor]]##, ##[[KeyPgDestructor Destructor]]##, ##[[KeyPgMemberFunction Function]]##, ##[[KeyPgOperator Operator]]##, ##[[KeyPgProperty Property]]## and ##[[KeyPgMemberSub Sub]]##. All members of a union are public and access control is not supported.


Revision [16157]

Edited on 2012-04-07 09:36:19 by FxMwikki [Union does not support variable-length strings]
Additions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (but unlike Type, Union can not contain variable-length strings, and more generally fields with constructors or destructors). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.
Deletions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (but unlike Type, Union can not contain variable-length strings). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.


Revision [16156]

Edited on 2012-04-07 04:21:43 by FxMwikki [Union does not support variable-length strings]
Additions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (but unlike Type, Union can not contain variable-length strings). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.
Deletions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (also unlike Type, Union can not contain variable-length strings). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.


Revision [16155]

Edited on 2012-04-07 04:18:13 by FxMwikki [nion does not support variable-length strings]
Additions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory (also unlike Type, Union can not contain variable-length strings). The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]##. Since they occupy the same space, only a single element can be used.
Unnamed unions can be nested inside a type structure and unnamed types can be nested inside an union. See Example.
Unions support member functions including ##[[KeyPgConstructor Constructor]]##, ##[[KeyPgDestructor Destructor]]##, ##[[KeyPgMemberFunction Function]]##, ##[[KeyPgOperator Operator]]##, ##[[KeyPgProperty Property]]## and ##[[KeyPgMemberSub Sub]]##. All members of a union are public and access control is not supported.
Deletions:
Unions are similar to a ##[[KeyPgType Type]]## structure, except that the elements of a union occupy the same space in memory. The size of the Union is the size of the largest data item. A data item can be an unnamed ##[[KeyPgType Type]]## . Since they occupy the same space, only a single element can be used.
Unnamed unions can be nested inside a type structure and unnamed types can be nested inside an union . See Example.
Unions support member functions including ##[[KeyPgConstructor Constructor]]##, ##[[KeyPgDestructor Destructor]]##, ##[[KeyPgMemberFunction Function]]##, ##[[KeyPgOperator Operator]]##, ##[[KeyPgProperty Property]]## and ##[[KeyPgMemberSub Sub]]##. All members of a union are public and access control is not supported.


Revision [16153]

Edited on 2012-04-06 09:58:36 by AgAmemnus [nion does not support variable-length strings]
Additions:
' Define a composite type.
Deletions:
'define a composite type


Revision [16152]

Edited on 2012-04-06 09:49:42 by AgAmemnus [nion does not support variable-length strings]
Additions:
' Example 1: bitfields.
type unitType
union
dim attributeMask as uinteger
type ' 32-bit uintegers can support up to 32 attributes.
isMilitary : 1 as uinteger
isMerchant : 1 as uinteger
end type
end union
dim myunit as unitType
myunit.isMilitary = 1
myunit.isMerchant = 1
print myunit.isMilitary ' Result: 1.
print myunit.isMerchant ' Result: 1.
print myunit.attributeMask ' Result: 3.
' Example 2.
' Define our union.
' Flags to let us know what to use in union.
' You can only use a single element of a union.
' Can only set one value in union.
MyComposite.ui = IsInteger ' Tells us this is an integer union.
Deletions:
'define our union
'Flags to let us know what to use in union.
'You can only use a single element of a union.
'Can only set one value in union
MyComposite.ui = IsInteger 'Tells us this is an integer union


Revision [14459]

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


Revision [13376]

The oldest known version of this page was created on 2008-05-20 06:36:01 by AntoniGual [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode