June 13, 2011
On 6/13/11 6:36 AM, Robert Clipsham wrote:
> I seemed to think the plan for complex numbers was to do what happened
> with associative arrays, that is, keep the language syntax, but have the
> feature implemented in the library. Is this not the case?

No, the current vision is to completely replace complex with library artifacts. Walter wants to keep the "i" postfix as a hack, but I think that's completely unnecessary.

A complex() convenience function should be useful. If anyone has the time, please create a pull request. It should never automatically create Complex with an integral type, as bearophile mentioned. For the rare cases where complex is needed with integrals, it should be fine to use Complex!int etc. directly.


Andrei

June 13, 2011
On Mon, 13 Jun 2011 08:36:32 -0500, Andrei Alexandrescu wrote:

> On 6/13/11 6:36 AM, Robert Clipsham wrote:
>> I seemed to think the plan for complex numbers was to do what happened with associative arrays, that is, keep the language syntax, but have the feature implemented in the library. Is this not the case?
> 
> No, the current vision is to completely replace complex with library artifacts. Walter wants to keep the "i" postfix as a hack, but I think that's completely unnecessary.
> 
> A complex() convenience function should be useful. If anyone has the time, please create a pull request. It should never automatically create Complex with an integral type, as bearophile mentioned. For the rare cases where complex is needed with integrals, it should be fine to use Complex!int etc. directly.

Sure, I'll add complex().

Regarding Complex!int:  I have explicitly restricted Complex to floating- point types.  Here is a message I sent to the Phobos mailing list, explaining why:

    http://lists.puremagic.com/pipermail/phobos/2010-April/000286.html

See also Don's reply to that message, it really drives the point home:

    http://lists.puremagic.com/pipermail/phobos/2010-April/000287.html

-Lars
June 13, 2011
On Mon, 13 Jun 2011 14:51:52 +0000, Lars T. Kyllingstad wrote:

> On Mon, 13 Jun 2011 08:36:32 -0500, Andrei Alexandrescu wrote:
> 
>> A complex() convenience function should be useful. If anyone has the time, please create a pull request. [...]
> 
> Sure, I'll add complex().

As promised: https://github.com/D-Programming-Language/phobos/pull/103

-Lars
June 13, 2011
Andrei:

> Walter wants to keep the "i" postfix as a hack, but I think that's completely unnecessary.

Before deciding I'd like to know the rationale to keep it. In principle I like handy complex number literals. In practice I don't use them often enough...

Another note: I'd like std.math.abs to perform what std.complex.Complex!T.abs does. So I will be able to use it functionally (currently std.math.abs is able to digest built-in complex numbers too):

alias Complex!double C;
C[] a = [C(1,2), C(2,4)];
auto m = map!abs(a);

Bye,
bearophile
1 2 3 4
Next ›   Last »