The D/Objective-C Bridge 0.2

Carlos Santander csantander619 at gmail.com
Tue Jan 15 05:52:55 PST 2008


Michel Fortin escribió:
> On 2008-01-15 04:17:13 -0500, Anders F Björklund <afb at algonet.se> said:
> 
>> If it's only a handful of items, you can use conditional compilation 
>> like: "version (Tango) { ... } else /* Phobos */ { ... }" instead :
>>
>> version (Tango)
>> import tango.io.Stdout;
>> else // Phobos
>> import std.stdio;
>>
>> void main()
>> {
>>    version (Tango)
>>    Stdout ("Hello, World!").newline;
>>    else // Phobos
>>    writefln("Hello, World!");
>> }
>>
>> Gets really painful, not to mention ugly, with larger diffs though.
>> wxD is somewhere in the borderline*, but still coping with both...
> 
> Well, perhaps it won't be truly two paralel versions in the source code, 
> but what I expect to be bothersome is testing. I'd need to compile 
> everything twice to make sure it work. How do I switch fast between 
> compiling against Tango and Phobos?
> 

As I've said many times, I use Tango from the SVN repos. In trunk/lib, there's a 
script install-gdc.sh. Call it once to install Tango, call it again with 
--uninstall to restore Phobos. That fast, that easy.

> What I could do to improve the situation is remove most of the 
> dependencies on the standard library. I could for instane remplace 
> toStringz with (str~\0).ptr, FieldTypeTuple!(T) with typeof(T.tupleof) 
> and so on. There's one thing I can't replace or remove: functions 
> dealing with the garbage collector, those are tied to the D runtime. 
> Everything else I could easily either "inline" manually or get rid of in 
> some way.
> 

You could also take the Derelict route. It has a layer between the library and 
either Tango or Phobos, so the runtime dependency remains there.

Tango also provides access to the GC.

> But I'm wondering now: who is seriously interested in using the 
> D/Objective-C bridge with Tango?
> 

Do you mean seriously as in doing a major project or similar? In that case, not 
me. However, I'm a Mac user, so I'm interested in this library, but I prefer 
Tango to Phobos.

> 
>> * especially "string" has been trouble with Phobos/Tango and 1.0/2.0
>> but it's starting to settle down to a single "toString()" method now
> 
> Yeah, that'd be another thing to bother about, although the version 
> trick above could handle for that just like everything else.
> 


-- 
Carlos Santander Bernal



More information about the Digitalmars-d-announce mailing list