Delegates

A game language would benefit greatly from a state based mechanic, such as delegates. Basically these are objects whose classes can be changed at runtime.

A light example:

delegate light
    - void toggle()
    - boolean status()

state on:light
    - void toggle()
        state off

    - boolean status()
        return true

state off:light
    - void toggle()
        state on

    - boolean status()
        return false

I’m not entirely sure about the syntax for changing states, it could either be setting a certain property, a method call or a keyword call as shown. Either way, this is quite cool.

I’m also not sure about inheritance, can a delegate ’subclass’ another delegate? What about states?

Either way, states can’t add any extra methods or properties to the class.

Oh, and they are fast because all they do is replace the class, so this is a good way to multiple functions without if statements all the time.

0 Responses to “Delegates”


Comments are currently closed.