On Nov 16, 2015, at 6:06 PM, Alex Harui <aha...@adobe.com> wrote:

> 
> 
> On 11/16/15, 12:51 AM, "Harbs" <harbs.li...@gmail.com> wrote:
> 
>> This seems like a partial solution. The thing with dot notation, is that
>> you can use anything — even elements that do not exist. You have a
>> mismatch between your xml and your code. In your example, xml.committer
>> will return an XMLList with two elements. xml.employee will return an
>> XMLList with a length() of 0. Unless we map the dot notation to child()
>> in the compiler, we will get a LOT of errors in existing E4X code.
>> Checking xml.element.length() is a very common way of checking that an
>> element exists.
> 
> Ah, ok. Didn’t know that.
> 
>> 
>> I guess we could use defineProperty for the cases when the Type of the
>> XML is not clear to the compiler, but even then, it will only work if the
>> client code is only checking elements which exist. It seems to me that
>> consistently failing on non-typed XML is easier to deal with then
>> sometimes-yes- sometimes-no access. But I could imagine others disagree.
> 
> One compiler feature I’ve wanted to try to implement I’ve referred to in
> the past as ‘frickin-strict’ or ‘super-strict’, although I think a better
> name would be warn-on-Object-access.  And it would basically emit a
> warning wherever your code read or wrote to something of type Object (and
> *).  I don’t think we’ve done this anywhere else in the compiler, but in
> theory we could also enable/disable that checking per-file or per-method.
> I’ve been told if you were to turn on such a feature, almost everybody’s
> code would generate 100’s of such warning.
> 
> So I think the summary of compiler changes is:
> 1) no more _as3_ prefixes on the function calls on XML/XMLList
> 2) detect read and write on XML/XMLList and convert read to child().  What
> about write()?

Good question. I think we should map xml.foo = <foo id=“1"/> to 
xml.replace(“foo”,new XML(“<foo id=\”1\”/>”));

> 3) detect for..in and foreach..in on XML/XMLList.  There is no foreach in
> JS, so foreach is converted into for..in with some glue code so the body
> of the loop executes correctly.  I think all we need is an
> elementNames():Array method that returns the array of element names.

OK. I can add a method like that.

> 4) detect read and write on plain Object and add warning.

Optionally. You’re probably right about something like this causing lots of 
warnings. I’m not sure if you’re thinking of some way to limit these warnings 
to places where it’s likely XML objects.

> Thoughts?
> -Alex
> 

Reply via email to