ReneMiner
09-04-2015, 10:53
Spooking through my head for a long time already, the thought how to have functional standard/primitive variables (Long, Dword etc.) without having an additional ".Subelementname" to add- means to be able to use them as the standard-type.
Think of
Alias Dword As SpecialDword
that would NOT make the "specialized Dword" functional now nor would it be possible to
Dim chi Like "SpecialDword" '- Error.
but would keep it's compatibility with any Dword, so can be treated as a Dword. (pass byref, peek, array scan etc.)
Now if I do this:
Type tSpecialDword
myVal As Dword
myFun As Function
Static myStat As Boolean
End Type
Function tSpecialDword.myFun() As Dword
' here it's Me.myVal that contains the DWord
Function = Me.myVal
End Function
Dim chi as tSpecialDword
chi.myVal = 123
I would have the specialized Dword that's real content is to find at chi.myVal and that were able to have as well Statics and Functions, maybe Const in future too.
But to read the value from the variable chi one would always have to append .myVal and this makes it impossible to use chi as a standard-Dword, what if chi were an array or subelement of another UDT here? It would become complicated...but we know Varptr(chi) equals Varptr(chi.myVal) and both means the same...
We could make all those ID's and handles that we have currently become functional - and also enable them to keep global track about their members & append their specific constants into their hability-zone instead of having them global because they would have the opportunity of statics/constants inside the appended UDT.
It would mean a special kind of udt that only consists of one standard-variable(Byte, Long, Dword etc.)
perhaps you'll understand better if read this syntax
Uses "console"
Type tSpecialDword Extends DWord ' this gives an Error - missing As-clause
'...not to mention simply putting "DWord" onto an empty line here...
myFun As Function
Static myStat As Boolean
End Type
Function tSpecialDword.myFun() As DWord
Function = Me
End Function
Dim chi As tSpecialDword ' = 123 ... instant assignement ...hm ok...
'in reality we would use a init-, load- or setup-function here mostly.
chi = 123
PrintL Str$(chi.myFun) ' should print 123
WaitKey
or
Type tSoundChannel As DWord ' this gives an Error too
' means: this UDT will consist of one Dword-Variable only.
' there can be statics & functions [+const] but no other subelements
Static globalVolume As Long
Play As Function
'...
End Type
I want to have "Me" as well as the variable-name to be treateable as a standard-type (Long & Dword mostly) without the requirement of a ".Subelementname" so either
"Type x Extends Dword" as well as "Type x As Dword"
could be an option in order to have functional handles, ID's, resource-slots, specialized variables etc.
As mentioned, their Static-properties were very nice place for type/unit/module-specific values, constants and global common values & settings that go to all of this specific type but is not of interest to any other parts of the application.
+++
Another idea were missing subelement-name on any UDT-variable means to use the first subelement.
Think of
Alias Dword As SpecialDword
that would NOT make the "specialized Dword" functional now nor would it be possible to
Dim chi Like "SpecialDword" '- Error.
but would keep it's compatibility with any Dword, so can be treated as a Dword. (pass byref, peek, array scan etc.)
Now if I do this:
Type tSpecialDword
myVal As Dword
myFun As Function
Static myStat As Boolean
End Type
Function tSpecialDword.myFun() As Dword
' here it's Me.myVal that contains the DWord
Function = Me.myVal
End Function
Dim chi as tSpecialDword
chi.myVal = 123
I would have the specialized Dword that's real content is to find at chi.myVal and that were able to have as well Statics and Functions, maybe Const in future too.
But to read the value from the variable chi one would always have to append .myVal and this makes it impossible to use chi as a standard-Dword, what if chi were an array or subelement of another UDT here? It would become complicated...but we know Varptr(chi) equals Varptr(chi.myVal) and both means the same...
We could make all those ID's and handles that we have currently become functional - and also enable them to keep global track about their members & append their specific constants into their hability-zone instead of having them global because they would have the opportunity of statics/constants inside the appended UDT.
It would mean a special kind of udt that only consists of one standard-variable(Byte, Long, Dword etc.)
perhaps you'll understand better if read this syntax
Uses "console"
Type tSpecialDword Extends DWord ' this gives an Error - missing As-clause
'...not to mention simply putting "DWord" onto an empty line here...
myFun As Function
Static myStat As Boolean
End Type
Function tSpecialDword.myFun() As DWord
Function = Me
End Function
Dim chi As tSpecialDword ' = 123 ... instant assignement ...hm ok...
'in reality we would use a init-, load- or setup-function here mostly.
chi = 123
PrintL Str$(chi.myFun) ' should print 123
WaitKey
or
Type tSoundChannel As DWord ' this gives an Error too
' means: this UDT will consist of one Dword-Variable only.
' there can be statics & functions [+const] but no other subelements
Static globalVolume As Long
Play As Function
'...
End Type
I want to have "Me" as well as the variable-name to be treateable as a standard-type (Long & Dword mostly) without the requirement of a ".Subelementname" so either
"Type x Extends Dword" as well as "Type x As Dword"
could be an option in order to have functional handles, ID's, resource-slots, specialized variables etc.
As mentioned, their Static-properties were very nice place for type/unit/module-specific values, constants and global common values & settings that go to all of this specific type but is not of interest to any other parts of the application.
+++
Another idea were missing subelement-name on any UDT-variable means to use the first subelement.