PHP and native arrays

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

PHP and native arrays

Elsass Philippe
Hello,

Unless I'm missing something, manipulating PHP native arrays is a pain in haxe. 
Sometimes you have lots of them, and sometimes arrays of arrays of arrays...

1. hashOfAssociativeArray efficient?

What is the rationale to copy each values into the new hash? It seems to work with:

function hashOfAssociativeArray<T>(arr:NativeArray) {
  var h = new Hash<T>();
  untyped h.h = arr;
  return h;
}


2. trace( untyped __php__("array('hello' => 'world', 42 => 'answer')") ) crash

trace() considers all NativeArrays as indexed arrays - associative arrays crash with index errors. I've submitted a bug.


3. what is the best way to make associative arrays compatible with Templo/Template?

I have to copy everything into Dynamic objects to be able to feed my templates...

--
Philippe

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

Re: PHP and native arrays

singmajesty
When I first read this message, I thought you said that "manipulating PHP  
native arrays [was] a pain in the Haxe"

I laughed to myself then realized this wasn't what you had written :)



On Fri, 02 Sep 2011 11:20:29 -0700, Elsass Philippe  
<[hidden email]> wrote:

> Hello,
>
> Unless I'm missing something, manipulating PHP native arrays is a pain in
> haxe.
> Sometimes you have lots of them, and sometimes arrays of arrays of  
> arrays...
>
> 1. hashOfAssociativeArray efficient?
>
> What is the rationale to copy each values into the new hash? It seems to
> work with:
>
> function hashOfAssociativeArray<T>(arr:NativeArray) {
>   var h = new Hash<T>();
>   untyped h.h = arr;
>   return h;
> }
>
>
> 2. trace( untyped __php__("array('hello' => 'world', 42 => 'answer')") )
> crash
>
> trace() considers all NativeArrays as indexed arrays - associative arrays
> crash with index errors. I've submitted a bug.
>
>
> 3. what is the best way to make associative arrays compatible with
> Templo/Template?
>
> I have to copy everything into Dynamic objects to be able to feed my
> templates...
>


--
Using Opera's revolutionary email client: http://www.opera.com/mail/

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