flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: [FALCONJX][FLEXJS] XML handling (was Re: [FlexJS] Back port)
Date Thu, 12 Nov 2015 17:28:17 GMT
I will spend some time looking into how the compiler sees XML Literals.

Regarding length(), delete, and extending Array:

If you extend Array, I would worry that some code like:

if (obj is Array)

will not do what the developer would expect.  And again, code hinting
would offer up methods that probably shouldn’t be exposed.

I can probably teach the compiler to map length() to length, but let’s
first nail down scenarios so we understand where we can hack and where we
shouldn’t.  I haven’t written any production apps that use XML, so I am
relying on input from you and others.

The key thing about the XML implementation is when you will need to know a
property (or attribute) changed, if ever.  You would only need to use
Object.defineProperties to immediately catch changes.  Otherwise, it is
reasonable to think of the APIs as queries.  XML is defined in
ActionScript as dynamic.  So really, it may be that you can get quite far
without immediate change detection.

Also, I recall past conversations where folks were doing things to XMLList
that the language guys never anticipated, like adding nodes from some
other XML tree to ab XMLList.  We have to keep in mind that we may not be
able to replicate 100% of E4x, but if we can get even 80% there, it will
be a major savings to folks with existing code bases.

And, of course, since the implementation should be swappable, we can build
an implementation that handles the most common cases and allow
extensibility or full replacement to get other cases.

So, given all that, if your XML class is dynamic, and attributes are just
added to the instance as properties with the @prefix and child nodes are
arrays of the child node name, I think that delete will do the right thing.

For XMLList, how common is it to delete an index and what does it do (does
it affect the XML the XMLList came from)?  We are having the compiler map
E4X syntax into new APIs on XML and XMLList, so maybe we do add a
removeChild to XML and I can get delete to call it.

Also, does deleting an index from an XMLList re-order the indexes or just
set that index to undefined/null.  If the latter, that should be free.

My understanding of the bigger picture is that folks get some XML,
manipulate it with E4X, and always call toXMLString() at the end.  If XML
and XMLList are dynamic, toXMLString can just walk the properties on each
node and no immediate change detection is needed.  Even length() would
just walk each property looking for property names that map to numbers and
return the highest number it found.  That would be slow, but it would work.


On 11/12/15, 7:10 AM, "Harbs" <harbs.lists@gmail.com> wrote:

>Another question regarding FalconJX:
>How easy will it be to handle xml literals? The most straightforward way
>I can think of that would be to convert:
>var myXML:XML = <root><node name=“fred”/><node name=“John”/></root>;
>var myXML:XML = new XML("<root><node name=\“fred\”/><node
>Right now I’m left with three open questions:
>1. Will it be hard to convert XMLList.length() into XMLList.length
>2. How can we deal with “delete” in the context of XML
>3. How to deal with XML literals

View raw message