Phobos/Tango Unification Plans

Don nospam at nospam.com.au
Mon Oct 13 00:31:46 PDT 2008


Benji Smith wrote:
> I was just looking through bearophile's library (which is based on 
> Phobos) and thinking about how it's too bad that I can't use it because 
> my code is all based on Tango.
> 
> I know there are plans currently in the works to implement a compatible 
> runtime layer, via Sean's druntime project. And it'll be a breath of 
> fresh air to get rid of the basic incompatibilities in the two runtimes.
> 
> But if that's all that happens, it'll still leave an undesirable 
> situation, since all the other userland stuff will be incompatible.
> 
> Eventually, any significantly complex project is likely to have some 
> dependent libraries built on top of both Phobos and Tango. At the very 
> least, string-processing routines from both libraries will get compiled 
> into the final executable.
> 
> Not only will that result in duplication of functionality (and code 
> bloat), but it'll also mean a bunch of bit-twiddling whenever sending a 
> Tango type into a Phobos-dependent library function (and vice versa).
> 
> Are there any plans in the works to mitigate that problem? Like, 
> perhaps, negotiating a common API so that at least the names and 
> argument types are the same in both libraries?
> 
> I'm sure the two libraries will always include different subsets of 
> functionality, but whenever they implement the same basic features, it'd 
> be great if they used a compatible API.
> 
> --benji


That could have some difficult aspects, but here's an uncomplicated 
second step: The math libraries for Tango and Phobos aren't merely 
compatible, they are THE SAME! They are a cut-and-paste of each other, 
with a couple of trivial name changes.
There are no licensing issues or personality clashes to worry about -- 
I've written most of both of them. They have no dependencies on anything 
else in either Phobos or Tango. I have write access to repositories of 
both Phobos and Tango.
YET -- there are two bodies of code! This is absolutely ridiculous, and 
it's driving me mad.

How can we turn this into ONE body of code?
It will only be possible if there is a namespace which is present in 
both Tango and Phobos. There are exactly three ways in which this can be 
done:
Either
(1) Tango needs to include part of the std namespace,
(2) Phobos needs to include part of the tango namespace, or
(3) Both need to start including a new namespace which is common to both.

Of these options, I think (2) is the least natural. For (1) to work, the 
modules invoved would need to be clearly designated as common.

---
Suggestion #1

The best situation I can imagine would be if Phobos started using the 
phobos namespace for stuff which is not common with Tango, and std was 
used for the common stuff.

My preferred option would be to remove tango.math.Math (stupid name 
anyway), combine it with tango.math.IEEE (another doubtful name) and 
rename it as std.math.
The more advanced math functions would remain in Tango, since I like the 
two-level heirachy which Tango provides. The advanced functions which 
are currently duplicated (eg, std.math.tgamma) would be removed from Phobos.

---

There are many other alternatives, perhaps someone will suggest a better 
or more acceptable alternative. I don't care, as long as I can stop 
having to copy & paste all my code.

Yes, lots of stuff is going to break. But I think we have to accept 
that. The potential gains from healing this massive schism in D are 
enormous.



More information about the Digitalmars-d mailing list