Terminology
fxm wrote: ↑Oct 16, 2022 14:14
All this on the same existing page: (TYPE) ?
I think is probably worthwhile to only mention it on
TYPE page and perhaps add a new page
TYPE (Nested) to document this new feature.
fxm wrote: ↑Oct 16, 2022 14:14
- anonymous inner Types/Unions,
- named inner Types/Unions.
yea, there is a number of overlapping concepts. fbc source comments use 'nested' and 'inner' somewhat interchangeably with respect to TYPE declarations. And 'scope' is used sometimes as a synonym for the concept of 'namespace'. TYPE is also a kind of namespace that can have other symbols declared within it's declarative scope. So it can be a bit of a mess.
Here is what I am thinking:
- when I refer to "TYPE" I usually am inferring "TYPE|UNION"
- "nested type" to refer to this new feature: a named TYPE only inside the namespace of another TYPE - it's not a field, only a declaration
- "anonymous inner TYPE" to refer to a structure inside a TYPE that has fields and adds size to the TYPE, but has no name
- "named inner type" should probably be avoided - fields are named and can be of a TYPE
Code: Select all
type T
union U '' nested type in T's namespace
a as short
b as byte
end union
fld as U '' field having type 'U'
union '' anonymous inner type
c as short
d as byte
end union
end type
print sizeof( T.U.a ) '' ok, accessing declaration
print sizeof( T.d ) '' ok, accessing declaration
dim x as T
print sizeof( x.fld.a ) '' ok, accessing fields
print x.fld.a '' ok, accessing fields
print sizeof( x.d ) '' ok, accessing field
print x.d '' ok, accessing field
print sizeof( x.U.a ) '' not allowed, U is not a field, U is a declaration
print x.U.a '' not allowed, U is not a field, U is a declaration