August 14, 2005
Ok, now I've finally had some time to play around again with D. I'm especially happy with the D syntax. On the other hand, there are many things that need more work. I hope even more volunteers could improve the DUI, Eclipse D plugin, Doxygen support and create a good DB library for D. DMD is an excellent reference compiler, thank you Walter.

I studied the latest dmd package and made some notes and questions, so here we go (tried to keep it short):

N: lex.html, operatoroverloading.html: opNotations === and !== used instead of is/!is

Q: ctod.html: Formatted printing + printf -> writef/writefln ?

Q: ctod.html: Data Structure Traversal, is it better to use foreach in the D example?

N: std.recls: the compilation fails on linux (gcc 3.4.4) stlsoft_null.h:line 194, func needs to be public?

Q: It seems that Phobos is missing std.inbuffer? I think most of the InBuffer functionality is possible to achieve with std.Streams.

Q: The Phobos manual is also missing std.math2 documentation, isn't it?

N: There seems to be a bug in std.boxer. Can be easily found by using the boxer with some primitives.

foobar.o(.gnu.linkonce.t_D3std5boxer8unbox_Aa5unboxFS3std5boxer3BoxZAa+0x4a):
In function `_D3std5boxer8unbox_Aa5unboxFS3std5boxer3BoxZAa':
foobar.d:563: undefined reference to `_assert_3std5boxer'

N: The recls_test_1.d & recls_test_2.d examples need some more work. First, there's the old cast-syntax:

$ dmd recls_test_1.d
recls_test_1.d(221): C style cast illegal, use cast(char*)("")
recls_test_1.d(235): C style cast illegal, use cast(char*)("")
recls_test_1.d(236): C style cast illegal, use cast(char*)("")
recls_test_1.d(239): C style cast illegal, use cast(char*)("")
$ dmd recls_test_2.d
recls_test_2.d(210): C style cast illegal, use cast(char*)("")
recls_test_2.d(229): C style cast illegal, use cast(char*)("")
recls_test_2.d(230): C style cast illegal, use cast(char*)("")
recls_test_2.d(233): C style cast illegal, use cast(char*)("")

Next, the printf-thing is kind of deprecated now that we have writef.

Finally, I can't figure it out how to link with recls.

---

Q: I would like to sort the following array:

interface A { ..., int opCmp(A other); }
class B : A { ..., int opCmp(A other) { ... } }

B[] items;
B ~= new B();
B.sort;		// <-- now why does this produce a segfault?

AFAIK the sort doesn't even call the opCmp-functions.

Q: How is it possible to create a multi-threaded application in D that doesn't eat up all CPU time? I know I can call some functions like fork() via the C api, but what I was looking for was a nice wait-function that could be called from the currently running thread (just like in Java).

Q: I think the DMD has some trouble with the imports. Whenever
I create a simple class hierarchy, I need to improvise with the
import-lines to prevent some nasty forward references or conflicts.
I've never encountered anything similar with C/C++/Java. Is there
anything that could just make this work? :)

N: I managed to fix a few bugs in the dmd examples. The new versions
can be found at http://users.utu.fi/jmjmak/stuff/dmd-fixes.zip.
I hope these fixes will be included in the future dmd releases :)

---

Jari-Matti


August 14, 2005
a subset of answers:

> N: There seems to be a bug in std.boxer. Can be easily found by using the boxer with some primitives.
>
> foobar.o(.gnu.linkonce.t_D3std5boxer8unbox_Aa5unboxFS3std5boxer3BoxZAa+0x4a):
> In function `_D3std5boxer8unbox_Aa5unboxFS3std5boxer3BoxZAa':
> foobar.d:563: undefined reference to `_assert_3std5boxer'

If you use std.boxer you have to compile with -release or rebuild phobos without -release.

> Q: I would like to sort the following array:
>
> interface A { ..., int opCmp(A other); }
> class B : A { ..., int opCmp(A other) { ... } }
>
> B[] items;
> B ~= new B();
> B.sort; // <-- now why does this produce a segfault?
>
> AFAIK the sort doesn't even call the opCmp-functions.

you want
int opCmp(Object other)
I don't know why the sort would seg-v. It should use Object.opCmp.

> Q: How is it possible to create a multi-threaded application in D that doesn't eat up all CPU time? I know I can call some functions like fork() via the C api, but what I was looking for was a nice wait-function that could be called from the currently running thread (just like in Java).

http://home.comcast.net/~benhinkle/locks/locks.html
is a port of Doug Lea's concurrent (non-container) utilities like locks,
conditions, barriers, latches and semaphores.

> Q: I think the DMD has some trouble with the imports. Whenever
> I create a simple class hierarchy, I need to improvise with the
> import-lines to prevent some nasty forward references or conflicts.
> I've never encountered anything similar with C/C++/Java. Is there
> anything that could just make this work? :)

I have one word: private private private. Public imports get all tangled up very easily. By private importing wherever possible the symbols imported won't bleed into dependent modules and cause conflicts.

> N: I managed to fix a few bugs in the dmd examples. The new versions
> can be found at http://users.utu.fi/jmjmak/stuff/dmd-fixes.zip.
> I hope these fixes will be included in the future dmd releases :)

I hope so, too. Thanks!