You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Josh Tynjala <jo...@bowlerhat.dev> on 2026/01/20 20:29:49 UTC
New AS3 Language Feature: Function Type Expressions
Hi folks,
I just wanted to take a moment to highlight a new ActionScript language
feature that I recently implemented in Royale's compiler: Function type
expressions. Or perhaps you might call them strict function types.
Basically, instead of using the Function type, like this:
var validate:Function;
You can define the function signature as a type, like this (The syntax is
pretty similar to TypeScript's):
var validate:(input:String)=>Boolean;
And then, the compiler can check for mismatches. The following assignment
will fail:
var validate:(input:String)=>Boolean = function(input:ByteArray):Boolean {
return false; }
It should give the following error:
Error: Implicit coercion of a value of type (input:ByteArray)=>Boolean to
an unrelated type (input:String)=>Boolean.
The syntax supports optional parameters and rest parameters. Optional
parameters would be equivalent to parameters that have a default value in a
regular function signature. However, you don't need to specify the default
value in the function type expression (assigned functions are allowed to
have different default values or to use rest instead), and you may use the
? token to indicate that a specific parameter is optional.
var func:(s?:String, ...rest):void;
You can even nest function type expressions.
var action:(callback:(result:Object)=>void):void;
I've created some documentation to help folks get started:
https://apache.github.io/royale-docs/features/as3/strict-function-types
--
Josh Tynjala
Bowler Hat LLC
https://bowlerhat.dev/
Re: New AS3 Language Feature: Function Type Expressions
Posted by Josh Tynjala <jo...@bowlerhat.dev>.
Yes, it does fall under the warning. The syntax will not be recognized by
other AS3 compilers, so raw source code won't work with them.
If someone compiles a SWC file with Royale, the other compilers can use it.
However, those compilers won't enforce the strict function types that are
included in SWC metadata like Royale would. They'll just see the Function
type without a signature and allow any function, which is how AS3 has
traditionally behaved.
--
Josh Tynjala
Bowler Hat LLC
https://bowlerhat.dev/
On Mon, Jan 26, 2026 at 12:08 PM Andrew Wetmore <co...@gmail.com> wrote:
> I will, and thanks.
>
> DOES it fall under the warning of 'don't use this if you want 100%
> compiler-neutrality?
>
>
> Andrew Wetmore
> Assistant VP, Marketing and Publicity, The ASF <http://aparch.org>
> Editor-Writer, Infra team, The ASF
>
> Editor, moosehousepress.com
>
>
> <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> >
> Virus-free.www.avast.com
> <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> >
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Mon, Jan 26, 2026 at 4:04 PM Josh Tynjala <jo...@bowlerhat.dev>
> wrote:
>
> > I don't think I added it to the right sidebar. Go ahead and add it, if
> you
> > like.
> >
> > I added it to the list of "New ActionScript language features" on the AS3
> > page, though.
> >
> > --
> > Josh Tynjala
> > Bowler Hat LLC
> > https://bowlerhat.dev/
> >
> >
> > On Mon, Jan 26, 2026 at 11:58 AM Andrew Wetmore <co...@gmail.com>
> > wrote:
> >
> > > This is a great add.
> > >
> > > Did you include this new page in the index of site pages that appears
> on
> > > the right? I don't see it. I can add it, if you like.
> > >
> > > And does this feature fall into the category of "New ActionScript
> > language
> > > features in Royale" on
> https://apache.github.io/royale-docs/features/as3
> > ?
> > > These come with a caution not to use them if you want your app to be
> 100%
> > > compiler-neutral.
> > >
> > > a
> > >
> > >
> > > Andrew Wetmore
> > > Assistant VP, Marketing and Publicity, The ASF <http://aparch.org>
> > > Editor-Writer, Infra team, The ASF
> > >
> > > Editor, moosehousepress.com
> > >
> > >
> > > <
> > >
> >
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> > > >
> > > Virus-free.www.avast.com
> > > <
> > >
> >
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> > > >
> > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> > >
> > > On Tue, Jan 20, 2026 at 4:33 PM Harbs <ha...@gmail.com> wrote:
> > >
> > > > Thank you Josh!!!
> > > >
> > > > This is probably my #1 feature I’ve been missing in ActionScript.
> > > >
> > > > This will do a world of good for type safety and being able to
> express
> > > > required types!
> > > >
> > > > I’m looking forward to making use of this!
> > > >
> > > > Harbs
> > > >
> > > > > On Jan 20, 2026, at 10:29 PM, Josh Tynjala <
> > joshtynjala@bowlerhat.dev>
> > > > wrote:
> > > > >
> > > > > Hi folks,
> > > > >
> > > > > I just wanted to take a moment to highlight a new ActionScript
> > language
> > > > > feature that I recently implemented in Royale's compiler: Function
> > type
> > > > > expressions. Or perhaps you might call them strict function types.
> > > > >
> > > > > Basically, instead of using the Function type, like this:
> > > > >
> > > > > var validate:Function;
> > > > >
> > > > > You can define the function signature as a type, like this (The
> > syntax
> > > is
> > > > > pretty similar to TypeScript's):
> > > > >
> > > > > var validate:(input:String)=>Boolean;
> > > > >
> > > > > And then, the compiler can check for mismatches. The following
> > > assignment
> > > > > will fail:
> > > > >
> > > > > var validate:(input:String)=>Boolean =
> > > function(input:ByteArray):Boolean
> > > > {
> > > > > return false; }
> > > > >
> > > > > It should give the following error:
> > > > >
> > > > > Error: Implicit coercion of a value of type
> > (input:ByteArray)=>Boolean
> > > to
> > > > > an unrelated type (input:String)=>Boolean.
> > > > >
> > > > > The syntax supports optional parameters and rest parameters.
> Optional
> > > > > parameters would be equivalent to parameters that have a default
> > value
> > > > in a
> > > > > regular function signature. However, you don't need to specify the
> > > > default
> > > > > value in the function type expression (assigned functions are
> allowed
> > > to
> > > > > have different default values or to use rest instead), and you may
> > use
> > > > the
> > > > > ? token to indicate that a specific parameter is optional.
> > > > >
> > > > > var func:(s?:String, ...rest):void;
> > > > >
> > > > > You can even nest function type expressions.
> > > > >
> > > > > var action:(callback:(result:Object)=>void):void;
> > > > >
> > > > > I've created some documentation to help folks get started:
> > > > >
> > > > >
> > >
> https://apache.github.io/royale-docs/features/as3/strict-function-types
> > > > >
> > > > > --
> > > > > Josh Tynjala
> > > > > Bowler Hat LLC
> > > > > https://bowlerhat.dev/
> > > >
> > > >
> > >
> >
>
Re: New AS3 Language Feature: Function Type Expressions
Posted by Andrew Wetmore <co...@gmail.com>.
I will, and thanks.
DOES it fall under the warning of 'don't use this if you want 100%
compiler-neutrality?
Andrew Wetmore
Assistant VP, Marketing and Publicity, The ASF <http://aparch.org>
Editor-Writer, Infra team, The ASF
Editor, moosehousepress.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
On Mon, Jan 26, 2026 at 4:04 PM Josh Tynjala <jo...@bowlerhat.dev>
wrote:
> I don't think I added it to the right sidebar. Go ahead and add it, if you
> like.
>
> I added it to the list of "New ActionScript language features" on the AS3
> page, though.
>
> --
> Josh Tynjala
> Bowler Hat LLC
> https://bowlerhat.dev/
>
>
> On Mon, Jan 26, 2026 at 11:58 AM Andrew Wetmore <co...@gmail.com>
> wrote:
>
> > This is a great add.
> >
> > Did you include this new page in the index of site pages that appears on
> > the right? I don't see it. I can add it, if you like.
> >
> > And does this feature fall into the category of "New ActionScript
> language
> > features in Royale" on https://apache.github.io/royale-docs/features/as3
> ?
> > These come with a caution not to use them if you want your app to be 100%
> > compiler-neutral.
> >
> > a
> >
> >
> > Andrew Wetmore
> > Assistant VP, Marketing and Publicity, The ASF <http://aparch.org>
> > Editor-Writer, Infra team, The ASF
> >
> > Editor, moosehousepress.com
> >
> >
> > <
> >
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> > >
> > Virus-free.www.avast.com
> > <
> >
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> > >
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > On Tue, Jan 20, 2026 at 4:33 PM Harbs <ha...@gmail.com> wrote:
> >
> > > Thank you Josh!!!
> > >
> > > This is probably my #1 feature I’ve been missing in ActionScript.
> > >
> > > This will do a world of good for type safety and being able to express
> > > required types!
> > >
> > > I’m looking forward to making use of this!
> > >
> > > Harbs
> > >
> > > > On Jan 20, 2026, at 10:29 PM, Josh Tynjala <
> joshtynjala@bowlerhat.dev>
> > > wrote:
> > > >
> > > > Hi folks,
> > > >
> > > > I just wanted to take a moment to highlight a new ActionScript
> language
> > > > feature that I recently implemented in Royale's compiler: Function
> type
> > > > expressions. Or perhaps you might call them strict function types.
> > > >
> > > > Basically, instead of using the Function type, like this:
> > > >
> > > > var validate:Function;
> > > >
> > > > You can define the function signature as a type, like this (The
> syntax
> > is
> > > > pretty similar to TypeScript's):
> > > >
> > > > var validate:(input:String)=>Boolean;
> > > >
> > > > And then, the compiler can check for mismatches. The following
> > assignment
> > > > will fail:
> > > >
> > > > var validate:(input:String)=>Boolean =
> > function(input:ByteArray):Boolean
> > > {
> > > > return false; }
> > > >
> > > > It should give the following error:
> > > >
> > > > Error: Implicit coercion of a value of type
> (input:ByteArray)=>Boolean
> > to
> > > > an unrelated type (input:String)=>Boolean.
> > > >
> > > > The syntax supports optional parameters and rest parameters. Optional
> > > > parameters would be equivalent to parameters that have a default
> value
> > > in a
> > > > regular function signature. However, you don't need to specify the
> > > default
> > > > value in the function type expression (assigned functions are allowed
> > to
> > > > have different default values or to use rest instead), and you may
> use
> > > the
> > > > ? token to indicate that a specific parameter is optional.
> > > >
> > > > var func:(s?:String, ...rest):void;
> > > >
> > > > You can even nest function type expressions.
> > > >
> > > > var action:(callback:(result:Object)=>void):void;
> > > >
> > > > I've created some documentation to help folks get started:
> > > >
> > > >
> > https://apache.github.io/royale-docs/features/as3/strict-function-types
> > > >
> > > > --
> > > > Josh Tynjala
> > > > Bowler Hat LLC
> > > > https://bowlerhat.dev/
> > >
> > >
> >
>
Re: New AS3 Language Feature: Function Type Expressions
Posted by Josh Tynjala <jo...@bowlerhat.dev>.
I don't think I added it to the right sidebar. Go ahead and add it, if you
like.
I added it to the list of "New ActionScript language features" on the AS3
page, though.
--
Josh Tynjala
Bowler Hat LLC
https://bowlerhat.dev/
On Mon, Jan 26, 2026 at 11:58 AM Andrew Wetmore <co...@gmail.com> wrote:
> This is a great add.
>
> Did you include this new page in the index of site pages that appears on
> the right? I don't see it. I can add it, if you like.
>
> And does this feature fall into the category of "New ActionScript language
> features in Royale" on https://apache.github.io/royale-docs/features/as3 ?
> These come with a caution not to use them if you want your app to be 100%
> compiler-neutral.
>
> a
>
>
> Andrew Wetmore
> Assistant VP, Marketing and Publicity, The ASF <http://aparch.org>
> Editor-Writer, Infra team, The ASF
>
> Editor, moosehousepress.com
>
>
> <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> >
> Virus-free.www.avast.com
> <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> >
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Tue, Jan 20, 2026 at 4:33 PM Harbs <ha...@gmail.com> wrote:
>
> > Thank you Josh!!!
> >
> > This is probably my #1 feature I’ve been missing in ActionScript.
> >
> > This will do a world of good for type safety and being able to express
> > required types!
> >
> > I’m looking forward to making use of this!
> >
> > Harbs
> >
> > > On Jan 20, 2026, at 10:29 PM, Josh Tynjala <jo...@bowlerhat.dev>
> > wrote:
> > >
> > > Hi folks,
> > >
> > > I just wanted to take a moment to highlight a new ActionScript language
> > > feature that I recently implemented in Royale's compiler: Function type
> > > expressions. Or perhaps you might call them strict function types.
> > >
> > > Basically, instead of using the Function type, like this:
> > >
> > > var validate:Function;
> > >
> > > You can define the function signature as a type, like this (The syntax
> is
> > > pretty similar to TypeScript's):
> > >
> > > var validate:(input:String)=>Boolean;
> > >
> > > And then, the compiler can check for mismatches. The following
> assignment
> > > will fail:
> > >
> > > var validate:(input:String)=>Boolean =
> function(input:ByteArray):Boolean
> > {
> > > return false; }
> > >
> > > It should give the following error:
> > >
> > > Error: Implicit coercion of a value of type (input:ByteArray)=>Boolean
> to
> > > an unrelated type (input:String)=>Boolean.
> > >
> > > The syntax supports optional parameters and rest parameters. Optional
> > > parameters would be equivalent to parameters that have a default value
> > in a
> > > regular function signature. However, you don't need to specify the
> > default
> > > value in the function type expression (assigned functions are allowed
> to
> > > have different default values or to use rest instead), and you may use
> > the
> > > ? token to indicate that a specific parameter is optional.
> > >
> > > var func:(s?:String, ...rest):void;
> > >
> > > You can even nest function type expressions.
> > >
> > > var action:(callback:(result:Object)=>void):void;
> > >
> > > I've created some documentation to help folks get started:
> > >
> > >
> https://apache.github.io/royale-docs/features/as3/strict-function-types
> > >
> > > --
> > > Josh Tynjala
> > > Bowler Hat LLC
> > > https://bowlerhat.dev/
> >
> >
>
Re: New AS3 Language Feature: Function Type Expressions
Posted by Andrew Wetmore <co...@gmail.com>.
This is a great add.
Did you include this new page in the index of site pages that appears on
the right? I don't see it. I can add it, if you like.
And does this feature fall into the category of "New ActionScript language
features in Royale" on https://apache.github.io/royale-docs/features/as3 ?
These come with a caution not to use them if you want your app to be 100%
compiler-neutral.
a
Andrew Wetmore
Assistant VP, Marketing and Publicity, The ASF <http://aparch.org>
Editor-Writer, Infra team, The ASF
Editor, moosehousepress.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
On Tue, Jan 20, 2026 at 4:33 PM Harbs <ha...@gmail.com> wrote:
> Thank you Josh!!!
>
> This is probably my #1 feature I’ve been missing in ActionScript.
>
> This will do a world of good for type safety and being able to express
> required types!
>
> I’m looking forward to making use of this!
>
> Harbs
>
> > On Jan 20, 2026, at 10:29 PM, Josh Tynjala <jo...@bowlerhat.dev>
> wrote:
> >
> > Hi folks,
> >
> > I just wanted to take a moment to highlight a new ActionScript language
> > feature that I recently implemented in Royale's compiler: Function type
> > expressions. Or perhaps you might call them strict function types.
> >
> > Basically, instead of using the Function type, like this:
> >
> > var validate:Function;
> >
> > You can define the function signature as a type, like this (The syntax is
> > pretty similar to TypeScript's):
> >
> > var validate:(input:String)=>Boolean;
> >
> > And then, the compiler can check for mismatches. The following assignment
> > will fail:
> >
> > var validate:(input:String)=>Boolean = function(input:ByteArray):Boolean
> {
> > return false; }
> >
> > It should give the following error:
> >
> > Error: Implicit coercion of a value of type (input:ByteArray)=>Boolean to
> > an unrelated type (input:String)=>Boolean.
> >
> > The syntax supports optional parameters and rest parameters. Optional
> > parameters would be equivalent to parameters that have a default value
> in a
> > regular function signature. However, you don't need to specify the
> default
> > value in the function type expression (assigned functions are allowed to
> > have different default values or to use rest instead), and you may use
> the
> > ? token to indicate that a specific parameter is optional.
> >
> > var func:(s?:String, ...rest):void;
> >
> > You can even nest function type expressions.
> >
> > var action:(callback:(result:Object)=>void):void;
> >
> > I've created some documentation to help folks get started:
> >
> > https://apache.github.io/royale-docs/features/as3/strict-function-types
> >
> > --
> > Josh Tynjala
> > Bowler Hat LLC
> > https://bowlerhat.dev/
>
>
Re: New AS3 Language Feature: Function Type Expressions
Posted by Harbs <ha...@gmail.com>.
Thank you Josh!!!
This is probably my #1 feature I’ve been missing in ActionScript.
This will do a world of good for type safety and being able to express required types!
I’m looking forward to making use of this!
Harbs
> On Jan 20, 2026, at 10:29 PM, Josh Tynjala <jo...@bowlerhat.dev> wrote:
>
> Hi folks,
>
> I just wanted to take a moment to highlight a new ActionScript language
> feature that I recently implemented in Royale's compiler: Function type
> expressions. Or perhaps you might call them strict function types.
>
> Basically, instead of using the Function type, like this:
>
> var validate:Function;
>
> You can define the function signature as a type, like this (The syntax is
> pretty similar to TypeScript's):
>
> var validate:(input:String)=>Boolean;
>
> And then, the compiler can check for mismatches. The following assignment
> will fail:
>
> var validate:(input:String)=>Boolean = function(input:ByteArray):Boolean {
> return false; }
>
> It should give the following error:
>
> Error: Implicit coercion of a value of type (input:ByteArray)=>Boolean to
> an unrelated type (input:String)=>Boolean.
>
> The syntax supports optional parameters and rest parameters. Optional
> parameters would be equivalent to parameters that have a default value in a
> regular function signature. However, you don't need to specify the default
> value in the function type expression (assigned functions are allowed to
> have different default values or to use rest instead), and you may use the
> ? token to indicate that a specific parameter is optional.
>
> var func:(s?:String, ...rest):void;
>
> You can even nest function type expressions.
>
> var action:(callback:(result:Object)=>void):void;
>
> I've created some documentation to help folks get started:
>
> https://apache.github.io/royale-docs/features/as3/strict-function-types
>
> --
> Josh Tynjala
> Bowler Hat LLC
> https://bowlerhat.dev/