ReneMiner
25-09-2016, 08:37
Lets have a look at this code:
Uses "console"
Type tVec2S
x As Single
y As Single
End Type
Type tVec3S Extends tVec2S
z As Single
End Type
Dim a As Long
Dim b As tVec2S
Dim c As tVec3S
PrintL TypeOf(a)
PrintL TypeOf(b)
PrintL TypeOf(c)
WaitKey
It runs without any error, but it does not print anything.
So TypeOf still is a dead keyword without any functionality.
:( :unguee::cray:
Lets think about
Dim a As Long
built-in primitive type information as Byte, Long, String, Variant etc. are stored internally as some numeral that i can retrieve when i abuse
thinBasic_VariableGetInfoEx - but thinCore.dll its not intended to be used from within thinBasic-scripts this way.
And i have to translate the number in retrieved MainType into its String-expression before when i want to
Dim foo Like TypeOf(a)
Should not be so difficult to make the already existing keyword TypeOf functional for primitive types ;)
But what if MainType holds 24? ( = %MainType_UDT )
So i think an UDT could have some built-in secret static udt-subelement that holds the name of the udt, automatic assigned when the type gets defined.
In case of the example above it would work like
Type tVec2S
Secret Static TypeOf As String = "TVEC2S" ' automatic done by thinCore
x As Single
y As Single
End Type
Type tVec3S Extends tVec2S
Secret Static TypeOf As String = "TVEC3S" ' thinCore should have a separate static for each udt-extension ;)
z As Single
End Type
Dim b As tVec2S
Dim c As tVec3S
PrintL TypeOf(b)
PrintL TypeOf(c)
' equals then:
PrintL b.TypeOf
PrintL c.TypeOf
Assume "Secret" something be done by thinCore in background when keyword "Type" encountered...
Currently an issue is that static subelement TypeOf-information of Vec3S overwrites the content of same named static subelement of Vec2S when assigning TypeOf.
Maybe an idea.
Uses "console"
Type tVec2S
x As Single
y As Single
End Type
Type tVec3S Extends tVec2S
z As Single
End Type
Dim a As Long
Dim b As tVec2S
Dim c As tVec3S
PrintL TypeOf(a)
PrintL TypeOf(b)
PrintL TypeOf(c)
WaitKey
It runs without any error, but it does not print anything.
So TypeOf still is a dead keyword without any functionality.
:( :unguee::cray:
Lets think about
Dim a As Long
built-in primitive type information as Byte, Long, String, Variant etc. are stored internally as some numeral that i can retrieve when i abuse
thinBasic_VariableGetInfoEx - but thinCore.dll its not intended to be used from within thinBasic-scripts this way.
And i have to translate the number in retrieved MainType into its String-expression before when i want to
Dim foo Like TypeOf(a)
Should not be so difficult to make the already existing keyword TypeOf functional for primitive types ;)
But what if MainType holds 24? ( = %MainType_UDT )
So i think an UDT could have some built-in secret static udt-subelement that holds the name of the udt, automatic assigned when the type gets defined.
In case of the example above it would work like
Type tVec2S
Secret Static TypeOf As String = "TVEC2S" ' automatic done by thinCore
x As Single
y As Single
End Type
Type tVec3S Extends tVec2S
Secret Static TypeOf As String = "TVEC3S" ' thinCore should have a separate static for each udt-extension ;)
z As Single
End Type
Dim b As tVec2S
Dim c As tVec3S
PrintL TypeOf(b)
PrintL TypeOf(c)
' equals then:
PrintL b.TypeOf
PrintL c.TypeOf
Assume "Secret" something be done by thinCore in background when keyword "Type" encountered...
Currently an issue is that static subelement TypeOf-information of Vec3S overwrites the content of same named static subelement of Vec2S when assigning TypeOf.
Maybe an idea.