Metadata probably deserves its own thread.

Fear not, there will be Metadata support in FlexJS.  IIRC, there was a
long thread about Metadata a long time ago, but now might be a good time
to re-collect the various uses of Metadata so we can understand how we
want to implement it, especially on the JS side.

Falcon already compiles Metadata and adds selected metadata tags to the
class definition just like MXMLC does.  You can set some options to
include some metadata tags and not others.  You get the metadata by
calling describeType or describeTypeJSON

For FalconJX, my guess would be that we would add metadata to the
FLEXJS_CLASS_INFO structure we add to generated classes and have to
manually maintain for parallel classes.  We'll have to create a
describeTypeJSON function mimics what the AS version returns.  The key
limitation that will affect existing third-party libraries is that
describeType returns XML and folks used e4x to parse it, and code like
that will not cross-compile.  Not sure if all of the major libraries used
describeTypeJSON or not.  If not, we might have to do some monkey patching
to get them to work.

An interesting outcome of the FalconJX proposed implementation is that
metadata access will probably be much faster in JS than in AS since it is
accessed as a property and not via some reflection API.  It makes you
wonder if we should change Falcon to also attach FLEXJS_CLASS_INFO
structures to classes so new AS code can get faster access to this sort of
metadata.

Then there is the question of what the compiler should do with Metadata,
if anything.  I believe there are three kinds of metadata today:

1) IDE metadata like [Inspectable] that the IDE uses to do its job and
generally does not end affect compiler output or end up in the output.
2) Compiler directives like [Bindable] and [ExcludeClass] which affect
what the compiler (including the ASDoc compiler) generates.  [Bindable]
also ends up in the output, IIRC.
3) Other metadata.  They don't affect what the compiler outputs and are
used at runtime.

Are there any other kinds of metadata?

The metadata syntax appears to be: open-square-bracket tag
optional-open-parenthesis optional-name-value pairs,
optional-close-parenthesis close-square-bracket.

Does anybody have any desire to change that?  Should we add an optional
name-value pair that determines if the metadata is kept in the output?
Looks like that's how it is done in Java annotations, and not getting the
compiler's list of kept metadata correct is a frequent issue for folks.

Should we provide some way to add other libraries that would affect
codegen for metadata?  Currently the compiler behavior for [Binding] is
hard coded.  No way to change what it generated and no way to add some
other metadata the changes some other codegen.

My main objection to metadata is that it is, for Flash/AIR, the slowest
possible convention for adding properties to a class.  I'd rather populate
a set of properties like we do for FLEXJS_CLASS_INFO in FlexJS.  It is
prone to typos: the compiler will not catch misspellings.  But it's here
and not going away.  But is it worth any cycles to try to make it better?

-Alex

On 2/28/14 6:59 AM, "Carlos Rovira" <[email protected]> wrote:

>>This got cut off so I'm not sure what your thoughts were.  I'm not a huge
>fan of MetaData but we will have it in FlexJS
>
>Alex, Metadata is one of the things we have in Flex and not available in
>pure JS. I'm a huge advocate of metadata, both for generating code at
>compilation time or for later processing at runtime. In Java Annotations
>are a huge step forward, and IMO in AS3/Flex Metadata is one of the
>features for people wanting to go Flex 4 or FlexJS. We can underestimate
>the importance of such feature for the future of FlexJS. As you're one of
>the main heads of the project, I'd like to convince you of the importance
>of taking Metadata seriously into account when planning whatever feature.
>Moreover, I'd like someday to be able to get a decent AOP functionality as
>we have in Java.

Reply via email to