On Mon, 05 Oct 2009 01:03:01 +0400, bearophile <bearophileh...@lycos.com> wrote:

Walter Bright:

The
big reason for moving it to a library type is the user defined type
capabilities of D have grown to the point where there is no longer much
of any advantage to having it built in.

If the compiler/language is now flexible enough to allow the creation of a very good complex number, and the compilation time for such library numbers is good enough, and they get compiled efficiently enough, then removing them from the language is positive. But is the compiler now good enough to allow to implement very good complex numbers in the std lib?

One problem is to have a good syntax to define and use complex numbers. Time ago I have even suggested to keep the complex syntax in the compiler, and move the implementation in the std lib.

Another problem that I think is present still is the lack of a method like opBool, that gets called in implicit boolean situations like if(somecomplex){...

A third and more serious question is if the library complex type avoids the pitfalls discussed in the page about built-in complex numbers in the digitalmars site.

Bye,
bearophile

I don't see any reason why if (someComplexNumber) { ... } should be a valid code, it hardly makes any sense for me. In fact, I am trying to avoid if (foo) as much as possible (unless foo is a bool, of course):

if (somePtr !is null) {
}

if (someInt != 0) {
}

but:

if (someCondition) {
}

I wouldn't like to sacrifice code clarity for saving a few keystrokes, but maybe it's just me.

Reply via email to