On Jul 31, 2013, at 7:55 AM, Dicebot <pub...@dicebot.lv> wrote:

> On Wednesday, 31 July 2013 at 14:43:21 UTC, Daniel Kozak wrote:
>> is there a way for AA to behave same as PHP?
> 
> I doubt it. This snippet suggests that AA's in PHP are not simply AA's and do 
> additionally track insertion order (or use some similar trick). Data in 
> associative arrays is organized in a way that allows fast key lookup and 
> iterating in an original order requires tracking extra state. Contrary to 
> PHP, D does care about performance so I see no way this can happen 
> automatically.

This seems more likely to be a library type.  I have something like this that I 
use very frequently at work where the behavior is pluggable, so it can be used 
as a cache that automatically does LIFO/FIFO eviction according to an age 
window, number of entries, etc.  Or none of those if all you want is a plain 
old hashtable.  It's not a tremendous amount of work to adapt an existing 
implementation to work this way.  The only annoying bit I ran into (at least 
with C++) is that the symbol lookup rules pretty much prevent overrides of 
existing functions to be mixed in via the policies.  Does alias this work 
around this problem in D?  I've never tried.

Reply via email to