"Phango" container classes

Bruce Adams tortoise_74 at yahoo.co.uk
Mon Oct 1 11:26:20 PDT 2007


Bill Baxter Wrote:

> I just decided to do a little experiment to see how hard it would be to 
> make Tango's containers work with Phobos.
> 
> Answer: less than an hour's work.
> 
> Here's all it takes:
> - Copy tango/util/collections/* to phango/util/collections/*.
> - Copy tango/core/Exception.di to phango/core/Exception.d
> - Replace all instances of 'tango' with 'phango'.
> - Replace all instances of 'toUtf8' with 'toString'
> - Comment out the IReader,IWriter imports in LinkMap.d
> - Comment out all function prototypes in Exception.d.
> - Make TracedException a simple subclass of Exception in Exception.d.
> - Comment out anything else in Exception.d that gives compiler errors.
> 
> Then voila!  You have a set of container classes for Phobos.
> 
> I did some rudimentary testing by copying all the unittests from the 
> containers to one big containers.d test program.  After changing Cout's 
> to writefln's, all seems to work like a charm.
> 
> So this is a possible option for anyone who would like a set of 
> Java-esque container classes to use with Phobos.  Certainly a heck of a 
> lot easier than trying to port any implementation of C++ std::map to D.  :-)
> 
> --bb

Good stuff. Have you posted the source anywhere?
  I see tango uses Red-black trees in some places so in those its STL equivalent or better anyway. I guess we will get all this stuff as soon as the tango / phobos incompatability is resolved. Out of interest, if you just throw the all incompatibles out of tango what kind of phango are we left with? Does it look like a worthwhile job?
I'm coming from the school of Phobos is standard, Tango is not (yet) perspective.

Regards,

Bruce.



More information about the Digitalmars-d mailing list