apache / royale-compiler

Apache Royale Compiler
https://royale.apache.org/
Apache License 2.0
95 stars 49 forks source link

Support for new AIR 50 SDK AS3 language features #219

Closed esidegallery closed 1 year ago

esidegallery commented 2 years ago

The new AIR 50 Beta SDK introduces support for null-conditional operators, nullish coalescing and verbatim strings, outlined here https://github.com/airsdk/Adobe-Runtime-Support/discussions/1699#discussioncomment-3653584 😁

  • null-conditional operators You can now write val = obj?.prop; as a shorthand for val = (obj == null) ? null : obj.prop;
  • nullish coalescing You can now write val = x ?? y; as a shorthand for val = (x != null) ? x : y;
  • verbatim strings You can now define a string with an @ symbol at the start and then you don't need to escape backslashes.. eg. @"c:\users\test.txt"
Harbs commented 1 year ago

@ajwfrost Maybe we should coordinate plans for language features to ensure a consistent roadmap?

greg-dove commented 1 year ago

Thanks heaps @piepie62. If someone else could review and approve the PR for swf then, assuming @joshtynjala is not already looking into the JS side, I could take a look at that this coming weekend.

ajwfrost commented 1 year ago

Hi @Harbs - yes, @joshtynjala had thought this would be a good idea too, and Adobe are fine with it. There are some technical things we'd had to do but my hope is that AIR would be able to adopt (or adapt) the Royale compiler i.e. we would have Royale as the primary source code for the compiler that ends up in the AIR SDK.

I'm meant to be having a call with one of our lawyers to confirm that (a) we would be able to take the Royale compiler, adapt it slightly and then distribute it with AIR SDK (which I think is fine, reading the licenses) - and (b) whether we can then contribute back our own updates into the Royale compiler (which is where I think I may have to escalate internally to try to get approvals...).

There have been loads of interesting suggestions in the thread that you just posted to (thanks for that hint re abstract classes!) so it's then a case of trying to work out which are highest priority and relatively straightforward to do. Some of the "compile-time only" ones are fairly straightforward (e.g. verbatim strings) but some of them are going to need changes also in the runtime. For example we added support in the compiler for operator overloading, but we've not published it yet because it is a bit of a workaround that needs the AIR runtime interpreter and JIT code to be updated in order for it to work. I hadn't even considered how that sort of thing might then need to work from the JS perspective...!

thanks

joshtynjala commented 1 year ago

If someone else could review and approve the PR for swf then, assuming @joshtynjala is not already looking into the JS side, I could take a look at that this coming weekend.

I have been working on my own implementation the new AS3 language features that will work in both SWF and JS. I may not merge this PR as-is, but I'll certainly look it over and borrow any ideas that may improve my final commits.

I want to write a good set of tests too, before I merge anything.

greg-dove commented 1 year ago

I have been working on my own implementation the new AS3 language features that will work in both SWF and JS. I may not merge this PR as-is, but I'll certainly look it over and borrow any ideas that may improve my final commits.

I want to write a good set of tests too, before I merge anything.

For some reason I had a premonition you might also have been looking into this, hence my check on that... no evidence, just a "feeling" :). I look forward to what eventuates from that, @joshtynjala. Once again, thanks also to @piepie62.

joshtynjala commented 1 year ago

New AIR 50 AS3 language features are now implemented in the Royale compiler.

There is currently one intentional difference from AIR 50 in the nullish coalescing operator, and I opened a discussion here: airsdk/Adobe-Runtime-Support#2327