"Type Extends" to protect ancestry type
issueid=644 08-06-2021 21:59
thinBasic MVPs
Number of reported issues by ReneMiner: 84
"Type Extends" to protect ancestry type
i don't find a better description you will understand after reading

The feature were pretty simple- a hidden Type-function, somehow like _Create() and _Destroy()
available to call as in the example below, maybe make it being a prefix of the Function or prefix
for the functions name that can be a prototype...

The function will return the typename maybe similar to TypeOf() alike "UDT.tSomeType"

BUT

the function inherits and can not be userdefined and the function is not created for udts that have in
their top line of Type-definition no EXTENDS-keyword.

Example

Type tBasicVectorS   ' (S for the single type used here)
  X As Single
  Y As Single

 [Readonly Property] Prototype Alias "_BaseType$" As Fundamental Method

  Function _BaseType$() As String 
    Function = "UDT.tBasicVectorS"
 End Function 
End Type
dim foo as tBasicVectorS
' TEST:
msgbox foo._Basetype$ 
           
 >>> ERROR: -

type-function thats name starting with underscore must not be called

msgbox foo.Prototype   ' shows "UDT.BasicVectorS"

' now a Type tHat Extends ...

Type tVector3DS Extends tBasicVectorS
    Z As Single
Function Prototype(
'   BEEP BEEP 
'  >>>>>>>ERROR
' duplicate function name: function Prototype already exists for this type inherited through Extends
End Type

' so far?... then i add one more:

Type tVectorColored3DS Extends tVector3DS
   rgba As Long 
  Function SetColor(vColor as Variant, Optional vRGBA as Variant, b As Byte, a as byte) As Long 
' vColor a String as Red, Green, Blue, Alpha or density, opacity...
' i let someone else figure this...
  End Function
End Type
' TEST 
Dim lar As tVectorColored3DS
MsgBox lar.Prototype
' should show "tBasicVectorS"
So Prototype here is not a secret property but the alias-name of a fundamental types function that
can not be used in a call since leading underscore is not permitted to call directly in a script. If
ProtoType Alias "_GetBasetype$" is just a static placeholder for the type function pointer and reacts therefor
like a Call_IfExists-version for types - or if its renamed - nobody will ever find out. But all will use it.
Important that it can not be replaced by a function of a type that Extends another type likewise the functions of a previous type are replaced by default - this kind of functions should just act as
"Hey you use an already existing functions name, but this is not possible on protected type methods"
Issue Details
Issue Number 644
Issue Type Feature
Project thinBasic
Category Core engine (thinCore.dll)
Status Suggested
Priority 4
Suggested Version 2.0
Implemented Version (none)
Milestone (none)
Votes for this feature 0
Votes against this feature 0
Assigned Users (none)
Tags (none)




+ Reply