Suggestions
vincent catrino
catrino at cbs.cnrs.fr
Mon Dec 4 00:33:09 PST 2006
Hi there,
I have been following D for about 1.5 year and I really like this
language. I use it for casual programming and for fun. I'm a
software engineer using mainly C, JAVA and FORTRAN 77.
There are a few things that I use all the time in C and JAVA and
that I really would appreciate to find in the D language.
* C99 allows the following :
int func( int n, int a[n][n] ) {
... do something ...
}
D forbids this. It is possible to have this in D for example by
creating a structure like this.
struct Mati {
int *ptr;
int dim;
int *opIndex(int i) { return ptr + i*dim; }
};
and rewriting func like this
int func( int n, int *ptr ) {
Mati m = new Mati();
m.ptr = ptr;
m.dim = n;
m[1][5] = 3;
}
Would it be possible to have this in D directly ? Or maybe there
is a cute D way to have this already and I woould be glad to learn
it.
* Indirection.
in C when you get a structure pointer you use the '->' operator
instead of '.' to access members. In D only '.' is allowed. Would
it be possible to have '->' too as a synomym for '.' ? This is
just syntaxic sugar and D works well without this but when working
in D I switch back to my C habits and naturally use '->'.
* JAVA has a base object type too which is used as the base class
for all other classes. In JAVA the basic object type provides
synchronization primitives which are quite useful :
void wait()
void wait( long timeout )
void notify()
void notifyAll()
Maybe it is already possible to do this in D and I haven't
understood how. If yes I would be glad to learn how to do so, if
not maybe these facilities might be added to the D object type ?
Best regards
Vincent
More information about the Digitalmars-d
mailing list