Re: Complex numbers are harder to use than in C

2016-11-22 Thread Marduk via Digitalmars-d-learn
On Sunday, 20 November 2016 at 11:46:04 UTC, Marc Schütz wrote: Try placing it outside the function. Method call syntax doesn't work with nested functions, see here: https://dlang.org/spec/function.html#pseudo-member "The reason why local symbols are not considered by UFCS, is to avoid unexp

Re: Complex numbers are harder to use than in C

2016-11-22 Thread Marduk via Digitalmars-d-learn
On Sunday, 20 November 2016 at 12:08:23 UTC, Ilya Yaroshenko wrote: You can use builtin complex numbers (cfloat/cdouble/creal). The idea of std.complex is wrong . Mir GLAS uses builtin complex numbers and I don't think they will be really deprecated. --Ilya Good to know! The builtin syntax i

Re: Complex numbers are harder to use than in C

2016-11-20 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 19 November 2016 at 19:42:27 UTC, Marduk wrote: On Saturday, 19 November 2016 at 16:17:08 UTC, Meta wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: [...] D used to support complex numbers in the language (actually it still does, they're just deprecated). This

Re: Complex numbers are harder to use than in C

2016-11-20 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 19 November 2016 at 20:24:09 UTC, Marduk wrote: On Saturday, 19 November 2016 at 12:55:57 UTC, Marc Schütz wrote: On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am

Re: Complex numbers are harder to use than in C

2016-11-20 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 19 November 2016 at 20:08:42 UTC, Marduk wrote: On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Something l

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 12:55:57 UTC, Marc Schütz wrote: On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Someth

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Something like auto I(T)(T im) if (isNumeric!T) { return complex

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 16:17:08 UTC, Meta wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: Dear all, I just discovered D and I am translating some numerical code I wrote in C. I was surprised to learn that there are at least two things that are easier in C than in

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Meta via Digitalmars-d-learn
On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: Dear all, I just discovered D and I am translating some numerical code I wrote in C. I was surprised to learn that there are at least two things that are easier in C than in D: + Writing complex numbers C: complex double z = 2.0 +

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Something like auto I(T)(T im) if (isNumeric!T) { return complex

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Something like auto I(T)(T im) if (isNumeric!T) { return complex(0, im); } unittest { auto x = 1 + 2.I; }