Many questions

bearophile bearophileHUGS at lycos.com
Sun May 3 16:53:53 PDT 2009


Hello, and welcome Fractal. I can give you some answers; other people will fill the missing ones.

I can see you come from C#. D isn't C#, and not everything C# does differently from D is an mistake of the D design. Sometimes it's just a different way to do things, sometimes it's a design that is more fit for the other features of D, some times it's a design error of D, and sometimes it's a design error of C#.


>- Why i cant use many files with the same module name?<

Because that's messy.


>I want to use modules like .NET or C++ namespaces and the file has 10K lines and finding a line takes many time...<

My serious (wise) advice is to use smaller files.


>- Why there is no ranged foreach in D1? - Why there is no pure keyword in D1?<

Because D is developed mostly by a person (Walter), and such person can't keep two (three) compilers updated. And maybe because Walter wants people to slowly leave D1 behind and use D2.


>- Why cent (128 bit integer) is not implemented?<

Probably because not enough people have asked for it, because it's not easy to find purposes for them, and because Don (and you) have not implemented them yet. LDC compiler already has a partial support for them, probably once LLVM 2.6 comes out they may become usable.


>- Why methods are virtual by default?<

To simplify the life of the programmer, I presume (see Java). And because smart compilers are supposed to magically devirtualize them.


>- Why enum uses int by default? why not ubyte?<

Probably because int/uint are the faster types to manage by the CPU, because today memory is cheap, and because even if you use an ubyte often you don't save memory anyway because the following variables in the stack/heap may be aligned to 4 bytes aniway, so you often end with 3 bytes of padding after it.


>- Why exists typedef and alias?<

Alias is very useful, to "change" name of member functions, to define different names and types, etc.

You can see why typedef is useful if you come from Pascal-like languages, and when you don't use much Object oriented programming. For example you may have some functions that take an array, with a typedef you can be sure it's the right kind of array and not an array with the same number of dimensions and the same base type.


>in modern languages like C#, i can not see these things (these are confusing)...<

Typedef isn't confusing. In the universe there are things that C# doesn't have yet. D is modern but has typedef.


>- Assosiative array: why stores the keys? why not the hashes?<

Where do you want to keep the keys?


>- Why no multiple inheritace?<

Probably because Walter thinks it's a complex feature that often you don't really need. D tries to be less quite complex than C++, even if this reduces the power of D a bit.


>if i have a simple (3 lines function) code and i need share it between many classes, i use an interface, and implementing the function in all the classes grows the code potentially. Simply if a class member name collides, threat as error. No virtual classes like C++...<

I don't understand you much. Have you tried a "template mixin"?


>is there any way to make a class like an opaque pointer? (but with the same sintax of a common class)<

I don't think so.


>- Why there is no XML module in Phobos for D1?<

Because Walter has not found the time to do it. Take a look at Phobos.


>- Is there any standard API like the .NET base classes for D?<

Nope. Not in Phobos. Maybe something vaguely similar may be created in the future.


>- Why the overrided method does not inherit the default values for arguments?<

I don't know. Maybe Walter has not thought about this yet.

Bye,
bearophile



More information about the Digitalmars-d mailing list