Event declarations and firing Events
Posted: Fri Jul 25, 2008 10:58 pm
Did you have any syntax in mind for Event declaration and for firing/Raising Events ?
- Code: Select all
# A Rat is like a Mouse but bigger and hairier with a longer naked tail
sig RatEventHandler(sender as Object, args as RatEventArgs) # exists - signature for an eventHandler
# event <eventId> as <sigId> #-- new syntax for event?
event ratEvent as RatEventHandler
def onRatEvent( args asRatEventArgs) # fireRatEvent invoking handlers/Observers
# lowlvl detail like C#
h as RatEventHandler? = RatEvent
if h
raise h, this, args
# OR hide detail handling - statementish
# raise <event>, <eventHandler commaSep argList>
raise ratEvent, this, args # trailing expr after eventname are arg vals to pass to handler/delegates
# OR functionish
# raise <eventId>( <eventHandler commaSep argList>)
raise ratEvent(this, args)