-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Currently in ActionScript, it's only possible to declare function signatures for methods and package level functions. It's not possible to declare signatures for variables and function paramters. The best you have is var foo:Function
or function foo(fun:Function):Function{}
.
This in my opinion is the biggest hole in the ActionScript type system. I have felt this lack for a very long time. It's very commonly felt in event handlers, but possibly a bigger issue is that it makes ActionScript a poor choice for functional-style programming.
If I had only one feature I could add to the language, it would be typed functions with signatures.
The exact syntax is less important than the type safety. My initial suggestion would be Vector style angle brackets with content like you'd use for an interface. Something like this: var fun:Function.<(ev:Event):void>
or function foo(callback:Function.<(handler:IAsyncTask):IAsyncTask>):void{}
.