D Conference Tango Phobos

Sean Kelly sean at f4.ca
Fri Sep 14 10:43:35 PDT 2007


Jascha Wetzel wrote:
> Sean Kelly wrote:
>> Well, the first issues to address are the few incompatibility points 
>> between Tango and Phobos within the runtime, the most visible being 
>> Object.toString in Phobos vs. Obejct.toUtf8 in Tango.  This likely 
>> means toUtf8 in Tango will have to change to toString, so if anyone 
>> absolutely hates the idea, you're welcome to say so :-)  However, I 
>> suspect there is a quiet majority using Phobos, so even valid 
>> arguments against the way it does things may have to be ignored if the 
>> change would break some user-visible portion of the Phobos library.  
>> Suggestions here are welcome also.
> 
> ridiculously, the only reason i can come up with, that kept me from 
> using tango in programs that don't use networking, is the verbose string 
> formatting syntax (i don't want to start a discussion about which one is 
> better. i consider it a matter of taste).

I go on about this a lot, but being from a C++ background I'm quite used 
to wrapping library routines to give them an appearance suitable for my 
application.  For formatting, it would be simple to do something like:

     import tango.text.convert.Layout;
     private static Layout layout;
     static this() { layout = new Layout(char); }

     char[] format( char[] fmt, ... ) {
         return layout.convert( fmt );
     }

Layout is stateless so there are no thread synchronization issues to 
worry about.

Tango was designed with these sort of customizations in mind, and tries 
to make very few assumptions about behavior in order to allow for the 
greatest possible flexibility.

For what it's worth, the topic of providing wrapper routines as a part 
of Tango has come up before, but in my experience every program has 
slightly different requirements, so it would be difficult to come up 
with a design that was universally appealing.  However, given the rather 
trivial nature of most wrappers (as demonstrated above), I don't expect 
this to be a significant burden.  It may be more than is expected of a 
novice programmer, but they typically have fewer demands about how a 
library should be designed as well :-)

> when tango and phobos will co-exist painlessly, i'll probably be using 
> std.stdio, std.format and everything else from tango :)

I'll admit that I prefer using simple functions like this in many cases 
as well.  My approach is only different in that I create wrappers like 
the above to provide functionality in the manner I prefer.


Sean



More information about the Digitalmars-d mailing list