The D/Objective-C Bridge 0.2

Michel Fortin michel.fortin at michelf.com
Tue Jan 15 05:06:52 PST 2008


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?

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.

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


> * 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.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d-announce mailing list