What about Extendable and CallExtension?

BlitzMax Forums/BlitzMax Programming/What about Extendable and CallExtension?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'd suggest to add two new keywords you can use like this:
Strict

Print New T1.GetName ( ) 'prints "T1"
Print New T2.GetName ( ) 'prints "T1 extended by T2"

Type T1
  Method GetName$ ( ) Extendable
    Return "T1" + CallExtension ( )
  EndMethod
EndType

Type T2
  Method GetName$ ( )
    Return " extended by T2"
  EndMethod
EndType

Sometimes I want to have a method which can't be overwritten, but be extended like Method New() or Method Delete().
So I'd suggest to add a keyword "Extendable" which can be used like "Abstract" or "Final" with the limit only to use it with methods.
This keyword says you can 'overwrite' this method, but your method will not be called instead of the super method, it'll be call when super method calls "CallExtension".
CallExtension has same params and return value like the method calling it and CallExtension can only be called from an extendable method.
This could also be used for event handlers like this:
...

Type TApplication
  ...

  Method OnEvent ( Event:TEvent ) Extendable
    Select Event.id
      Case EVENT_APPTERMINATE
        End
      Case ...
        ...
      Default
        Return CallExtension ( Event ) 'All methods overwriting this one cannot receive an appterminate event.
    EndMethod
  EndMethod
EndType


How do think about it?