Working with QName - recursive compiler behavior?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Working with QName - recursive compiler behavior?

Armén
This is a bit too recursive, no?

//From API reference on haxe.org

extern class flash.utils.QName
{
      function new( p1 : Dynamic, ?localName : QName ) : Void
}

The only way to create a QName object is to call the constructor. The
constructor accepts a QName object as parameter. How is one supposed
to create QName objects again?

I am confused %)

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Working with QName - recursive compiler behavior?

Pimm Hogeling
As indicated by the question mark before localName, that argument (slash parameter) is optional.

On Mon, Aug 24, 2009 at 14:08, [hidden email] <[hidden email]> wrote:
This is a bit too recursive, no?

//From API reference on haxe.org

extern class flash.utils.QName
{
     function new( p1 : Dynamic, ?localName : QName ) : Void
}

The only way to create a QName object is to call the constructor. The
constructor accepts a QName object as parameter. How is one supposed
to create QName objects again?

I am confused %)

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Working with QName - recursive compiler behavior?

Armén
I need the optional parameter, because I need to retrieve a node with
a local name.

On Mon, Aug 24, 2009 at 14:11, Pimm Hogeling<[hidden email]> wrote:

> As indicated by the question mark before localName, that argument (slash
> parameter) is optional.
>
> On Mon, Aug 24, 2009 at 14:08, [hidden email] <[hidden email]>
> wrote:
>>
>> This is a bit too recursive, no?
>>
>> //From API reference on haxe.org
>>
>> extern class flash.utils.QName
>> {
>>      function new( p1 : Dynamic, ?localName : QName ) : Void
>> }
>>
>> The only way to create a QName object is to call the constructor. The
>> constructor accepts a QName object as parameter. How is one supposed
>> to create QName objects again?
>>
>> I am confused %)
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Working with QName - recursive compiler behavior?

Tyler MacLeod
I'm not sure how to answer it for Haxe, but here is the Actionscript answer:

According to Adobe Livedocs, the QName constructor should be signed as  

function new (p1:Dynamic, ?p2:Dynamic)

If anything other then a QName is passed into the second parameter, it is turned into a String and that is used as the localname.
As well, if you do not need a uri, you can just pass in the first parameter and it will ignore the URL.

-- Tyler MacLeod


On Mon, Aug 24, 2009 at 9:25 AM, [hidden email] <[hidden email]> wrote:
I need the optional parameter, because I need to retrieve a node with
a local name.

On Mon, Aug 24, 2009 at 14:11, Pimm Hogeling<[hidden email]> wrote:
> As indicated by the question mark before localName, that argument (slash
> parameter) is optional.
>
> On Mon, Aug 24, 2009 at 14:08, [hidden email] <[hidden email]>
> wrote:
>>
>> This is a bit too recursive, no?
>>
>> //From API reference on haxe.org
>>
>> extern class flash.utils.QName
>> {
>>      function new( p1 : Dynamic, ?localName : QName ) : Void
>> }
>>
>> The only way to create a QName object is to call the constructor. The
>> constructor accepts a QName object as parameter. How is one supposed
>> to create QName objects again?
>>
>> I am confused %)
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Working with QName - recursive compiler behavior?

Armén
The problem is that the compiler complains if I pass anything other
than a QName as the second parameter to QName constructor. Which makes
it a chicken-egg problem. I have a namespaced XML file which I use
flash.xml.XML object to work with, and I cannot retrieve children
nodes unless I use fully qualified name. What I do now is cast the
second parameter to String:

xml.child(new QName(xml.namespace(), cast "mynode"));

But not only is it ugly, it is also unsafe. Not to mention the whole
expression is fugly as hell. Not necessarily haXes fault, but maybe
people here have tips to share, regarding working with flash.xml.XML
objects?

On Mon, Aug 24, 2009 at 14:53, Tyler MacLeod<[hidden email]> wrote:

> I'm not sure how to answer it for Haxe, but here is the Actionscript answer:
> According to Adobe Livedocs, the QName constructor should be signed as
>
> function new (p1:Dynamic, ?p2:Dynamic)
>
> If anything other then a QName is passed into the second parameter, it is
> turned into a String and that is used as the localname.
> As well, if you do not need a uri, you can just pass in the first parameter
> and it will ignore the URL.
> -- Tyler MacLeod
>
>
> On Mon, Aug 24, 2009 at 9:25 AM, [hidden email] <[hidden email]>
> wrote:
>>
>> I need the optional parameter, because I need to retrieve a node with
>> a local name.
>>
>> On Mon, Aug 24, 2009 at 14:11, Pimm Hogeling<[hidden email]>
>> wrote:
>> > As indicated by the question mark before localName, that argument (slash
>> > parameter) is optional.
>> >
>> > On Mon, Aug 24, 2009 at 14:08, [hidden email] <[hidden email]>
>> > wrote:
>> >>
>> >> This is a bit too recursive, no?
>> >>
>> >> //From API reference on haxe.org
>> >>
>> >> extern class flash.utils.QName
>> >> {
>> >>      function new( p1 : Dynamic, ?localName : QName ) : Void
>> >> }
>> >>
>> >> The only way to create a QName object is to call the constructor. The
>> >> constructor accepts a QName object as parameter. How is one supposed
>> >> to create QName objects again?
>> >>
>> >> I am confused %)
>> >>
>> >> --
>> >> haXe - an open source web programming language
>> >> http://haxe.org
>> >
>> >
>> > --
>> > haXe - an open source web programming language
>> > http://haxe.org
>> >
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Working with QName - recursive compiler behavior?

Justin Donaldson
I ran into this same problem a while ago...
This seems to be a different type of problem than the recursive parameterized classes (Hash<T>,  Hash<Hash<T>>, Hash<Hash<Hash<T>>>, etc.).  The trade-off there is speed, the types are not recursively parsed so the compiler doesn't have to get to the "bottom" of  a parameterized collection.

On the surface, this self-referential typing problem seems like it could be solved by 'ignoring it'.  The Typing pass of the compiler would just have to include the current partially-parsed Class definition in the Type tree as it is parsing it.  The currently parsed Class definition could be invalid, but the compiler should figure this out and throw an error once it finishes parsing, so no harm done.  I can't imagine this would cause a speed hit either.

Best,
-Justin



On Mon, Aug 24, 2009 at 9:25 AM, [hidden email] <[hidden email]> wrote:
The problem is that the compiler complains if I pass anything other
than a QName as the second parameter to QName constructor. Which makes
it a chicken-egg problem. I have a namespaced XML file which I use
flash.xml.XML object to work with, and I cannot retrieve children
nodes unless I use fully qualified name. What I do now is cast the
second parameter to String:

xml.child(new QName(xml.namespace(), cast "mynode"));

But not only is it ugly, it is also unsafe. Not to mention the whole
expression is fugly as hell. Not necessarily haXes fault, but maybe
people here have tips to share, regarding working with flash.xml.XML
objects?

On Mon, Aug 24, 2009 at 14:53, Tyler MacLeod<[hidden email]> wrote:
> I'm not sure how to answer it for Haxe, but here is the Actionscript answer:
> According to Adobe Livedocs, the QName constructor should be signed as
>
> function new (p1:Dynamic, ?p2:Dynamic)
>
> If anything other then a QName is passed into the second parameter, it is
> turned into a String and that is used as the localname.
> As well, if you do not need a uri, you can just pass in the first parameter
> and it will ignore the URL.
> -- Tyler MacLeod
>
>
> On Mon, Aug 24, 2009 at 9:25 AM, [hidden email] <[hidden email]>
> wrote:
>>
>> I need the optional parameter, because I need to retrieve a node with
>> a local name.
>>
>> On Mon, Aug 24, 2009 at 14:11, Pimm Hogeling<[hidden email]>
>> wrote:
>> > As indicated by the question mark before localName, that argument (slash
>> > parameter) is optional.
>> >
>> > On Mon, Aug 24, 2009 at 14:08, [hidden email] <[hidden email]>
>> > wrote:
>> >>
>> >> This is a bit too recursive, no?
>> >>
>> >> //From API reference on haxe.org
>> >>
>> >> extern class flash.utils.QName
>> >> {
>> >>      function new( p1 : Dynamic, ?localName : QName ) : Void
>> >> }
>> >>
>> >> The only way to create a QName object is to call the constructor. The
>> >> constructor accepts a QName object as parameter. How is one supposed
>> >> to create QName objects again?
>> >>
>> >> I am confused %)
>> >>
>> >> --
>> >> haXe - an open source web programming language
>> >> http://haxe.org
>> >
>> >
>> > --
>> > haXe - an open source web programming language
>> > http://haxe.org
>> >
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org



--
Justin Donaldson
PhD Candidate, Informatics
Indiana University
http://www.scwn.net
aim: iujjd
twitter: jjdonald

--
haXe - an open source web programming language
http://haxe.org