stupid question? how do I define an Object

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

stupid question? how do I define an Object

Nathan
Hi,

I'm simply looking to define a standard Object in haXe, one like you'll
find in js and most languages - as in define the general type 'Object'
not a specific kind of object, basically a collection of key value pairs
where the key is a String and the value is Dynamic, a collection of {
?:String = ?:Dynamic } and which you can iterate over (without an
iterable interface).

bit confused,

Best,

Nathan

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

Re: stupid question? how do I define an Object

Simon Krajewski
  Hi,

you are probably looking for Hash<Dynamic>.

         var h = new Hash<Dynamic>();
         h.set("int", 1);
         h.set("string", "foo");
         h.set("object", new Main());
         for (i in h.keys())
             trace(i + ": " +h.get(i));

Regards
Simon

Am 15.08.2010 20:38, schrieb Nathan:

> Hi,
>
> I'm simply looking to define a standard Object in haXe, one like
> you'll find in js and most languages - as in define the general type
> 'Object' not a specific kind of object, basically a collection of key
> value pairs where the key is a String and the value is Dynamic, a
> collection of { ?:String = ?:Dynamic } and which you can iterate over
> (without an iterable interface).
>
> bit confused,
>
> Best,
>
> Nathan
>

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

Re: stupid question? how do I define an Object

Nathan
Almost, more of a

   class Object extends Hash<Dynamic> {};
   var h = new Object;
   h.int = 1;
   h.string = "foo";

and which compiles to pretty much the same in JS, simply need to defin
the type Object.

Cheers,

Nathan

Simon Krajewski wrote:

>  Hi,
>
> you are probably looking for Hash<Dynamic>.
>
>         var h = new Hash<Dynamic>();
>         h.set("int", 1);
>         h.set("string", "foo");
>         h.set("object", new Main());
>         for (i in h.keys())
>             trace(i + ": " +h.get(i));
>
> Regards
> Simon
>
> Am 15.08.2010 20:38, schrieb Nathan:
>> Hi,
>>
>> I'm simply looking to define a standard Object in haXe, one like
>> you'll find in js and most languages - as in define the general type
>> 'Object' not a specific kind of object, basically a collection of key
>> value pairs where the key is a String and the value is Dynamic, a
>> collection of { ?:String = ?:Dynamic } and which you can iterate over
>> (without an iterable interface).
>>
>> bit confused,
>>
>> Best,
>>
>> Nathan
>>
>
>


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

Re: stupid question? how do I define an Object

tommedema
Unfortunately I don't think there is an object type. But this is probably what you mean:

var obj:Dynamic = { }
obj.int = 1;
obj.string = "foo";

- Tom

2010/8/15 Nathan <[hidden email]>
Almost, more of a

 class Object extends Hash<Dynamic> {};
 var h = new Object;
 h.int = 1;
 h.string = "foo";

and which compiles to pretty much the same in JS, simply need to defin the type Object.

Cheers,

Nathan


Simon Krajewski wrote:
 Hi,

you are probably looking for Hash<Dynamic>.

       var h = new Hash<Dynamic>();
       h.set("int", 1);
       h.set("string", "foo");
       h.set("object", new Main());
       for (i in h.keys())
           trace(i + ": " +h.get(i));

Regards
Simon

Am 15.08.2010 20:38, schrieb Nathan:
Hi,

I'm simply looking to define a standard Object in haXe, one like you'll find in js and most languages - as in define the general type 'Object' not a specific kind of object, basically a collection of key value pairs where the key is a String and the value is Dynamic, a collection of { ?:String = ?:Dynamic } and which you can iterate over (without an iterable interface).

bit confused,

Best,

Nathan





--
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: stupid question? how do I define an Object

Nathan
Cheers Tom,

That's close enough, it's not iterable but can't have everything I guess!

Many Regards,

Nathan

Tom wrote:

> Unfortunately I don't think there is an object type. But this is probably
> what you mean:
>
> var obj:Dynamic = { }
> obj.int = 1;
> obj.string = "foo";
>
> - Tom
>
> 2010/8/15 Nathan <[hidden email]>
>
>> Almost, more of a
>>
>>  class Object extends Hash<Dynamic> {};
>>  var h = new Object;
>>  h.int = 1;
>>  h.string = "foo";
>>
>> and which compiles to pretty much the same in JS, simply need to defin the
>> type Object.
>>
>> Cheers,
>>
>> Nathan
>>
>>
>> Simon Krajewski wrote:
>>
>>>  Hi,
>>>
>>> you are probably looking for Hash<Dynamic>.
>>>
>>>        var h = new Hash<Dynamic>();
>>>        h.set("int", 1);
>>>        h.set("string", "foo");
>>>        h.set("object", new Main());
>>>        for (i in h.keys())
>>>            trace(i + ": " +h.get(i));
>>>
>>> Regards
>>> Simon
>>>
>>> Am 15.08.2010 20:38, schrieb Nathan:
>>>
>>>> Hi,
>>>>
>>>> I'm simply looking to define a standard Object in haXe, one like you'll
>>>> find in js and most languages - as in define the general type 'Object' not a
>>>> specific kind of object, basically a collection of key value pairs where the
>>>> key is a String and the value is Dynamic, a collection of { ?:String =
>>>> ?:Dynamic } and which you can iterate over (without an iterable interface).
>>>>
>>>> bit confused,
>>>>
>>>> Best,
>>>>
>>>> Nathan
>>>>
>>>>
>>>
>> --
>> 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: stupid question? how do I define an Object

Tony Polinelli
sure is! ;P

var d:Dynamic = {}
d.int = 1;
d.string = "foo";

for(field in Reflect.fields(d))
{
     trace(Reflect.field(f, field));
}



On Mon, Aug 16, 2010 at 9:15 AM, Nathan <[hidden email]> wrote:
Cheers Tom,

That's close enough, it's not iterable but can't have everything I guess!

Many Regards,

Nathan


Tom wrote:
Unfortunately I don't think there is an object type. But this is probably
what you mean:

var obj:Dynamic = { }
obj.int = 1;
obj.string = "foo";

- Tom

2010/8/15 Nathan <[hidden email]>

Almost, more of a

 class Object extends Hash<Dynamic> {};
 var h = new Object;
 h.int = 1;
 h.string = "foo";

and which compiles to pretty much the same in JS, simply need to defin the
type Object.

Cheers,

Nathan


Simon Krajewski wrote:

 Hi,

you are probably looking for Hash<Dynamic>.

      var h = new Hash<Dynamic>();
      h.set("int", 1);
      h.set("string", "foo");
      h.set("object", new Main());
      for (i in h.keys())
          trace(i + ": " +h.get(i));

Regards
Simon

Am 15.08.2010 20:38, schrieb Nathan:

Hi,

I'm simply looking to define a standard Object in haXe, one like you'll
find in js and most languages - as in define the general type 'Object' not a
specific kind of object, basically a collection of key value pairs where the
key is a String and the value is Dynamic, a collection of { ?:String =
?:Dynamic } and which you can iterate over (without an iterable interface).

bit confused,

Best,

Nathan



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




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



--
Tony Polinelli
http://touchmypixel.com

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

Re: stupid question? how do I define an Object

Nathan
cool - followed everybodies pointers and managed to implement a js.Object :)

#if js
import Reflect;
extern class Object implements Dynamic<Dynamic>, implements
ArrayAccess<Dynamic> {
   public static function __init__() : Void {
     untyped __js__('Object.prototype.iterator = function() { return
Reflect.fields(this).iterator(); }');
   }
   public function new(o:Dynamic) : Void;
   public function iterator() : Iterator<Int>;
}
#end

test code:

   var o:Object = new Object({
     name: "nathan",
     gender: "male",
     foo: function(e:String) { return e; }
   });
   for(i in o) {
     trace( i + " " + o[i]);
   }

or:

   function output(o:Object) {
     for(i in o) {
       trace( i + " " + o[i]);
     }
   }

Thanks all,

Nathan


Tony Polinelli wrote:

> sure is! ;P
>
> var d:Dynamic = {}
> d.int = 1;
> d.string = "foo";
>
> for(field in Reflect.fields(d))
> {
>      trace(Reflect.field(f, field));
> }
>
>
>
> On Mon, Aug 16, 2010 at 9:15 AM, Nathan <[hidden email]> wrote:
>
>> Cheers Tom,
>>
>> That's close enough, it's not iterable but can't have everything I guess!
>>
>> Many Regards,
>>
>> Nathan
>>
>>
>> Tom wrote:
>>
>>> Unfortunately I don't think there is an object type. But this is probably
>>> what you mean:
>>>
>>> var obj:Dynamic = { }
>>> obj.int = 1;
>>> obj.string = "foo";
>>>
>>> - Tom
>>>
>>> 2010/8/15 Nathan <[hidden email]>
>>>
>>>  Almost, more of a
>>>>  class Object extends Hash<Dynamic> {};
>>>>  var h = new Object;
>>>>  h.int = 1;
>>>>  h.string = "foo";
>>>>
>>>> and which compiles to pretty much the same in JS, simply need to defin
>>>> the
>>>> type Object.
>>>>
>>>> Cheers,
>>>>
>>>> Nathan
>>>>
>>>>
>>>> Simon Krajewski wrote:
>>>>
>>>>   Hi,
>>>>> you are probably looking for Hash<Dynamic>.
>>>>>
>>>>>       var h = new Hash<Dynamic>();
>>>>>       h.set("int", 1);
>>>>>       h.set("string", "foo");
>>>>>       h.set("object", new Main());
>>>>>       for (i in h.keys())
>>>>>           trace(i + ": " +h.get(i));
>>>>>
>>>>> Regards
>>>>> Simon
>>>>>
>>>>> Am 15.08.2010 20:38, schrieb Nathan:
>>>>>
>>>>>  Hi,
>>>>>> I'm simply looking to define a standard Object in haXe, one like you'll
>>>>>> find in js and most languages - as in define the general type 'Object'
>>>>>> not a
>>>>>> specific kind of object, basically a collection of key value pairs
>>>>>> where the
>>>>>> key is a String and the value is Dynamic, a collection of { ?:String =
>>>>>> ?:Dynamic } and which you can iterate over (without an iterable
>>>>>> interface).
>>>>>>
>>>>>> bit confused,
>>>>>>
>>>>>> Best,
>>>>>>
>>>>>> Nathan
>>>>>>
>>>>>>
>>>>>>
>>>>>  --
>>>> 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: stupid question? how do I define an Object

Martijn Loots
Nathan, this would be soooo nice as a code snippet on haxe.org... ;)

On Mon, 16 Aug 2010, Nathan wrote:

> cool - followed everybodies pointers and managed to implement a js.Object :)
>
> #if js
> import Reflect;
> extern class Object implements Dynamic<Dynamic>, implements
> ArrayAccess<Dynamic> {
>  public static function __init__() : Void {
>    untyped __js__('Object.prototype.iterator = function() { return
> Reflect.fields(this).iterator(); }');
>  }
>  public function new(o:Dynamic) : Void;
>  public function iterator() : Iterator<Int>;
> }
> #end
>
> test code:
>
>  var o:Object = new Object({
>    name: "nathan",
>    gender: "male",
>    foo: function(e:String) { return e; }
>  });
>  for(i in o) {
>    trace( i + " " + o[i]);
>  }
>
> or:
>
>  function output(o:Object) {
>    for(i in o) {
>      trace( i + " " + o[i]);
>    }
>  }
>
> Thanks all,
>
> Nathan
>
>
> Tony Polinelli wrote:
>> sure is! ;P
>>
>> var d:Dynamic = {}
>> d.int = 1;
>> d.string = "foo";
>>
>> for(field in Reflect.fields(d))
>> {
>>      trace(Reflect.field(f, field));
>> }
>>
>>
>>
>> On Mon, Aug 16, 2010 at 9:15 AM, Nathan <[hidden email]> wrote:
>>
>>> Cheers Tom,
>>>
>>> That's close enough, it's not iterable but can't have everything I guess!
>>>
>>> Many Regards,
>>>
>>> Nathan
>>>
>>>
>>> Tom wrote:
>>>
>>>> Unfortunately I don't think there is an object type. But this is probably
>>>> what you mean:
>>>>
>>>> var obj:Dynamic = { }
>>>> obj.int = 1;
>>>> obj.string = "foo";
>>>>
>>>> - Tom
>>>>
>>>> 2010/8/15 Nathan <[hidden email]>
>>>>
>>>>  Almost, more of a
>>>>>  class Object extends Hash<Dynamic> {};
>>>>>  var h = new Object;
>>>>>  h.int = 1;
>>>>>  h.string = "foo";
>>>>>
>>>>> and which compiles to pretty much the same in JS, simply need to defin
>>>>> the
>>>>> type Object.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Nathan
>>>>>
>>>>>
>>>>> Simon Krajewski wrote:
>>>>>
>>>>>   Hi,
>>>>>> you are probably looking for Hash<Dynamic>.
>>>>>>
>>>>>>       var h = new Hash<Dynamic>();
>>>>>>       h.set("int", 1);
>>>>>>       h.set("string", "foo");
>>>>>>       h.set("object", new Main());
>>>>>>       for (i in h.keys())
>>>>>>           trace(i + ": " +h.get(i));
>>>>>>
>>>>>> Regards
>>>>>> Simon
>>>>>>
>>>>>> Am 15.08.2010 20:38, schrieb Nathan:
>>>>>>
>>>>>>  Hi,
>>>>>>> I'm simply looking to define a standard Object in haXe, one like
>>>>>>> you'll
>>>>>>> find in js and most languages - as in define the general type 'Object'
>>>>>>> not a
>>>>>>> specific kind of object, basically a collection of key value pairs
>>>>>>> where the
>>>>>>> key is a String and the value is Dynamic, a collection of { ?:String =
>>>>>>> ?:Dynamic } and which you can iterate over (without an iterable
>>>>>>> interface).
>>>>>>>
>>>>>>> bit confused,
>>>>>>>
>>>>>>> Best,
>>>>>>>
>>>>>>> Nathan
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>  --
>>>>> haXe - an open source web programming language
>>>>> http://haxe.org
>>>>>
>>>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>>
>>
>>
>>
>
>
>

--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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

Re: stupid question? how do I define an Object

Nathan
Hi Martin,

tbh it'll probably end up as (or part of) a library v soon, have since
defined all the native js/ecmascript-262 objects and global functions
which makes quite a big difference to js dev'ing in haXe - will no doubt
have an update on list soon.

cheers,

Nathan

Martijn Loots wrote:

> Nathan, this would be soooo nice as a code snippet on haxe.org... ;)
>
> On Mon, 16 Aug 2010, Nathan wrote:
>
>> cool - followed everybodies pointers and managed to implement a
>> js.Object :)
>>
>> #if js
>> import Reflect;
>> extern class Object implements Dynamic<Dynamic>, implements
>> ArrayAccess<Dynamic> {
>>  public static function __init__() : Void {
>>    untyped __js__('Object.prototype.iterator = function() { return
>> Reflect.fields(this).iterator(); }');
>>  }
>>  public function new(o:Dynamic) : Void;
>>  public function iterator() : Iterator<Int>;
>> }
>> #end
>>
>> test code:
>>
>>  var o:Object = new Object({
>>    name: "nathan",
>>    gender: "male",
>>    foo: function(e:String) { return e; }
>>  });
>>  for(i in o) {
>>    trace( i + " " + o[i]);
>>  }
>>
>> or:
>>
>>  function output(o:Object) {
>>    for(i in o) {
>>      trace( i + " " + o[i]);
>>    }
>>  }
>>
>> Thanks all,
>>
>> Nathan
>>
>>
>> Tony Polinelli wrote:
>>> sure is! ;P
>>>
>>> var d:Dynamic = {}
>>> d.int = 1;
>>> d.string = "foo";
>>>
>>> for(field in Reflect.fields(d))
>>> {
>>>      trace(Reflect.field(f, field));
>>> }
>>>
>>>
>>>
>>> On Mon, Aug 16, 2010 at 9:15 AM, Nathan <[hidden email]> wrote:
>>>
>>>> Cheers Tom,
>>>>
>>>> That's close enough, it's not iterable but can't have everything I
>>>> guess!
>>>>
>>>> Many Regards,
>>>>
>>>> Nathan
>>>>
>>>>
>>>> Tom wrote:
>>>>
>>>>> Unfortunately I don't think there is an object type. But this is
>>>>> probably
>>>>> what you mean:
>>>>>
>>>>> var obj:Dynamic = { }
>>>>> obj.int = 1;
>>>>> obj.string = "foo";
>>>>>
>>>>> - Tom
>>>>>
>>>>> 2010/8/15 Nathan <[hidden email]>
>>>>>
>>>>>  Almost, more of a
>>>>>>  class Object extends Hash<Dynamic> {};
>>>>>>  var h = new Object;
>>>>>>  h.int = 1;
>>>>>>  h.string = "foo";
>>>>>>
>>>>>> and which compiles to pretty much the same in JS, simply need to
>>>>>> defin
>>>>>> the
>>>>>> type Object.
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Nathan
>>>>>>
>>>>>>
>>>>>> Simon Krajewski wrote:
>>>>>>
>>>>>>   Hi,
>>>>>>> you are probably looking for Hash<Dynamic>.
>>>>>>>
>>>>>>>       var h = new Hash<Dynamic>();
>>>>>>>       h.set("int", 1);
>>>>>>>       h.set("string", "foo");
>>>>>>>       h.set("object", new Main());
>>>>>>>       for (i in h.keys())
>>>>>>>           trace(i + ": " +h.get(i));
>>>>>>>
>>>>>>> Regards
>>>>>>> Simon
>>>>>>>
>>>>>>> Am 15.08.2010 20:38, schrieb Nathan:
>>>>>>>
>>>>>>>  Hi,
>>>>>>>> I'm simply looking to define a standard Object in haXe, one like
>>>>>>>> you'll
>>>>>>>> find in js and most languages - as in define the general type
>>>>>>>> 'Object'
>>>>>>>> not a
>>>>>>>> specific kind of object, basically a collection of key value pairs
>>>>>>>> where the
>>>>>>>> key is a String and the value is Dynamic, a collection of {
>>>>>>>> ?:String =
>>>>>>>> ?:Dynamic } and which you can iterate over (without an iterable
>>>>>>>> interface).
>>>>>>>>
>>>>>>>> bit confused,
>>>>>>>>
>>>>>>>> Best,
>>>>>>>>
>>>>>>>> Nathan
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>  --
>>>>>> 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: stupid question? how do I define an Object

Michiel Crefcoeur
ECMAScript objects in here too ;-) http://code.google.com/p/haxetacy/source/browse/#hg/org/ecmascript (not ready)
anyway, nice to see so many of us working on making the js target more useful.
would be a good idea to combine some efforts of these various projects at some time in the near future.

2010/8/17 Nathan <[hidden email]>
Hi Martin,

tbh it'll probably end up as (or part of) a library v soon, have since defined all the native js/ecmascript-262 objects and global functions which makes quite a big difference to js dev'ing in haXe - will no doubt have an update on list soon.

cheers,

Nathan


Martijn Loots wrote:
Nathan, this would be soooo nice as a code snippet on haxe.org... ;)

On Mon, 16 Aug 2010, Nathan wrote:

cool - followed everybodies pointers and managed to implement a js.Object :)

#if js
import Reflect;
extern class Object implements Dynamic<Dynamic>, implements ArrayAccess<Dynamic> {
 public static function __init__() : Void {
  untyped __js__('Object.prototype.iterator = function() { return Reflect.fields(this).iterator(); }');
 }
 public function new(o:Dynamic) : Void;
 public function iterator() : Iterator<Int>;
}
#end

test code:

 var o:Object = new Object({
  name: "nathan",
  gender: "male",
  foo: function(e:String) { return e; }
 });
 for(i in o) {
  trace( i + " " + o[i]);
 }

or:

 function output(o:Object) {
  for(i in o) {
    trace( i + " " + o[i]);
  }
 }

Thanks all,

Nathan


Tony Polinelli wrote:
sure is! ;P

var d:Dynamic = {}
d.int = 1;
d.string = "foo";

for(field in Reflect.fields(d))
{
    trace(Reflect.field(f, field));
}



On Mon, Aug 16, 2010 at 9:15 AM, Nathan <[hidden email]> wrote:

Cheers Tom,

That's close enough, it's not iterable but can't have everything I guess!

Many Regards,

Nathan


Tom wrote:

Unfortunately I don't think there is an object type. But this is probably
what you mean:

var obj:Dynamic = { }
obj.int = 1;
obj.string = "foo";

- Tom

2010/8/15 Nathan <[hidden email]>

 Almost, more of a
 class Object extends Hash<Dynamic> {};
 var h = new Object;
 h.int = 1;
 h.string = "foo";

and which compiles to pretty much the same in JS, simply need to defin
the
type Object.

Cheers,

Nathan


Simon Krajewski wrote:

 Hi,
you are probably looking for Hash<Dynamic>.

     var h = new Hash<Dynamic>();
     h.set("int", 1);
     h.set("string", "foo");
     h.set("object", new Main());
     for (i in h.keys())
         trace(i + ": " +h.get(i));

Regards
Simon

Am 15.08.2010 20:38, schrieb Nathan:

 Hi,
I'm simply looking to define a standard Object in haXe, one like you'll
find in js and most languages - as in define the general type 'Object'
not a
specific kind of object, basically a collection of key value pairs
where the
key is a String and the value is Dynamic, a collection of { ?:String =
?:Dynamic } and which you can iterate over (without an iterable
interface).

bit confused,

Best,

Nathan



 --
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: stupid question? how do I define an Object

Martijn Loots
In reply to this post by Nathan
Wow. You seem to be on a roll... Nice work.

On Tue, 17 Aug 2010, Nathan wrote:

> Hi Martin,
>
> tbh it'll probably end up as (or part of) a library v soon, have since
> defined all the native js/ecmascript-262 objects and global functions which
> makes quite a big difference to js dev'ing in haXe - will no doubt have an
> update on list soon.
>
> cheers,
>
> Nathan
>
> Martijn Loots wrote:
>> Nathan, this would be soooo nice as a code snippet on haxe.org... ;)
>>
>> On Mon, 16 Aug 2010, Nathan wrote:
>>
>>> cool - followed everybodies pointers and managed to implement a js.Object
>>> :)
>>>
>>> #if js
>>> import Reflect;
>>> extern class Object implements Dynamic<Dynamic>, implements
>>> ArrayAccess<Dynamic> {
>>>  public static function __init__() : Void {
>>>    untyped __js__('Object.prototype.iterator = function() { return
>>> Reflect.fields(this).iterator(); }');
>>>  }
>>>  public function new(o:Dynamic) : Void;
>>>  public function iterator() : Iterator<Int>;
>>> }
>>> #end
>>>
>>> test code:
>>>
>>>  var o:Object = new Object({
>>>    name: "nathan",
>>>    gender: "male",
>>>    foo: function(e:String) { return e; }
>>>  });
>>>  for(i in o) {
>>>    trace( i + " " + o[i]);
>>>  }
>>>
>>> or:
>>>
>>>  function output(o:Object) {
>>>    for(i in o) {
>>>      trace( i + " " + o[i]);
>>>    }
>>>  }
>>>
>>> Thanks all,
>>>
>>> Nathan
>>>
>>>
>>> Tony Polinelli wrote:
>>>> sure is! ;P
>>>>
>>>> var d:Dynamic = {}
>>>> d.int = 1;
>>>> d.string = "foo";
>>>>
>>>> for(field in Reflect.fields(d))
>>>> {
>>>>      trace(Reflect.field(f, field));
>>>> }
>>>>
>>>>
>>>>
>>>> On Mon, Aug 16, 2010 at 9:15 AM, Nathan <[hidden email]> wrote:
>>>>
>>>>> Cheers Tom,
>>>>>
>>>>> That's close enough, it's not iterable but can't have everything I
>>>>> guess!
>>>>>
>>>>> Many Regards,
>>>>>
>>>>> Nathan
>>>>>
>>>>>
>>>>> Tom wrote:
>>>>>
>>>>>> Unfortunately I don't think there is an object type. But this is
>>>>>> probably
>>>>>> what you mean:
>>>>>>
>>>>>> var obj:Dynamic = { }
>>>>>> obj.int = 1;
>>>>>> obj.string = "foo";
>>>>>>
>>>>>> - Tom
>>>>>>
>>>>>> 2010/8/15 Nathan <[hidden email]>
>>>>>>
>>>>>>  Almost, more of a
>>>>>>>  class Object extends Hash<Dynamic> {};
>>>>>>>  var h = new Object;
>>>>>>>  h.int = 1;
>>>>>>>  h.string = "foo";
>>>>>>>
>>>>>>> and which compiles to pretty much the same in JS, simply need to defin
>>>>>>> the
>>>>>>> type Object.
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Nathan
>>>>>>>
>>>>>>>
>>>>>>> Simon Krajewski wrote:
>>>>>>>
>>>>>>>   Hi,
>>>>>>>> you are probably looking for Hash<Dynamic>.
>>>>>>>>
>>>>>>>>       var h = new Hash<Dynamic>();
>>>>>>>>       h.set("int", 1);
>>>>>>>>       h.set("string", "foo");
>>>>>>>>       h.set("object", new Main());
>>>>>>>>       for (i in h.keys())
>>>>>>>>           trace(i + ": " +h.get(i));
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Simon
>>>>>>>>
>>>>>>>> Am 15.08.2010 20:38, schrieb Nathan:
>>>>>>>>
>>>>>>>>  Hi,
>>>>>>>>> I'm simply looking to define a standard Object in haXe, one like
>>>>>>>>> you'll
>>>>>>>>> find in js and most languages - as in define the general type
>>>>>>>>> 'Object'
>>>>>>>>> not a
>>>>>>>>> specific kind of object, basically a collection of key value pairs
>>>>>>>>> where the
>>>>>>>>> key is a String and the value is Dynamic, a collection of { ?:String
>>>>>>>>> =
>>>>>>>>> ?:Dynamic } and which you can iterate over (without an iterable
>>>>>>>>> interface).
>>>>>>>>>
>>>>>>>>> bit confused,
>>>>>>>>>
>>>>>>>>> Best,
>>>>>>>>>
>>>>>>>>> Nathan
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>  --
>>>>>>> haXe - an open source web programming language
>>>>>>> http://haxe.org
>>>>>>>
>>>>>>>
>>>>> --
>>>>> haXe - an open source web programming language
>>>>> http://haxe.org
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>
>
>

--
-Martijn    @..@    ( Martijn Loots       -  Hengelo  [NL] )
-          (`--')   ( martijn<@>cosix.com -  www.cosix.com )
-         ( >__< )  ----------------------------------------
-         ^^^  ^^^  (   Netwerken, Security, Open Source   )

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