Re: Please rid me of this goto

2016-06-25 Thread Patrick Schluter via Digitalmars-d
On Friday, 24 June 2016 at 20:34:38 UTC, deadalnix wrote: On Friday, 24 June 2016 at 10:33:43 UTC, Patrick Schluter wrote: On Friday, 24 June 2016 at 10:11:11 UTC, deadalnix wrote: On Friday, 24 June 2016 at 08:40:26 UTC, Patrick Schluter wrote: On Thursday, 23 June 2016 at 20:01:26 UTC,

Re: Please rid me of this goto

2016-06-24 Thread deadalnix via Digitalmars-d
On Friday, 24 June 2016 at 10:33:43 UTC, Patrick Schluter wrote: On Friday, 24 June 2016 at 10:11:11 UTC, deadalnix wrote: On Friday, 24 June 2016 at 08:40:26 UTC, Patrick Schluter wrote: On Thursday, 23 June 2016 at 20:01:26 UTC, deadalnix wrote: On Thursday, 23 June 2016 at 19:24:54 UTC, via

Re: Please rid me of this goto

2016-06-24 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 24 June 2016 at 15:17:52 UTC, Ola Fosheim Grøstad wrote: On Friday, 24 June 2016 at 13:51:33 UTC, Andrei Alexandrescu wrote: On 06/24/2016 02:58 AM, Martin Tschierschke wrote: Second: Just look at Wikipedia and take the IEEE floating point standard:

Re: Please rid me of this goto

2016-06-24 Thread Smoke Adams via Digitalmars-d
On Friday, 24 June 2016 at 03:22:11 UTC, Timon Gehr wrote: On 24.06.2016 04:36, Smoke Adams wrote: You do realize that e^(-1/t)^t is a counter example? e^(-1/t) -> 0 as t -> 0 t -> 0 as t -> 0 That's not a counterexample to anything I said. ^ is discontinuous at (0,0) and indeed,

Re: Please rid me of this goto

2016-06-24 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 24 June 2016 at 13:51:33 UTC, Andrei Alexandrescu wrote: On 06/24/2016 02:58 AM, Martin Tschierschke wrote: Second: Just look at Wikipedia and take the IEEE floating point standard: https://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_power_of_zero Scrolling down, I see how

Re: Please rid me of this goto

2016-06-24 Thread Andrei Alexandrescu via Digitalmars-d
On 06/24/2016 10:03 AM, Kagamin wrote: On Thursday, 23 June 2016 at 23:33:46 UTC, Timon Gehr wrote: I don't want to argue this at all. x^^0 is an empty product no matter what set I choose x and 0 from. 0^^0 = 1 is the only reasonable convention, and this is absolutely painfully obvious from

Re: Please rid me of this goto

2016-06-24 Thread Kagamin via Digitalmars-d
On Thursday, 23 June 2016 at 23:33:46 UTC, Timon Gehr wrote: I don't want to argue this at all. x^^0 is an empty product no matter what set I choose x and 0 from. 0^^0 = 1 is the only reasonable convention, and this is absolutely painfully obvious from where I stand. What context are you using

Re: Please rid me of this goto

2016-06-24 Thread Timon Gehr via Digitalmars-d
On 24.06.2016 08:11, H. S. Teoh via Digitalmars-d wrote: On Fri, Jun 24, 2016 at 05:22:11AM +0200, Timon Gehr via Digitalmars-d wrote: [...] (BTW: It would be fine with me if 0.0^^0.0 was NaN -- that's a completely different case than the one at hand: pow on integers.) That's even worse. So

Re: Please rid me of this goto

2016-06-24 Thread Andrei Alexandrescu via Digitalmars-d
On 06/24/2016 02:58 AM, Martin Tschierschke wrote: Second: Just look at Wikipedia and take the IEEE floating point standard: https://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_power_of_zero Scrolling down, I see how IEEE prescribes pown(0, 0) to return 1. I guess that's a good practical

Re: Please rid me of this goto

2016-06-24 Thread Andrei Alexandrescu via Digitalmars-d
On 06/23/2016 06:08 PM, Seb wrote: [1] https://github.com/wilzbach/perf-d/blob/master/test_pow.d [2] https://github.com/wilzbach/perf-d/blob/master/test_powi.d Thanks for this work! I shamelessly copied it into https://issues.dlang.org/show_bug.cgi?id=16200 to measure the proposed pow

Re: Please rid me of this goto

2016-06-24 Thread Patrick Schluter via Digitalmars-d
On Friday, 24 June 2016 at 10:11:11 UTC, deadalnix wrote: On Friday, 24 June 2016 at 08:40:26 UTC, Patrick Schluter wrote: On Thursday, 23 June 2016 at 20:01:26 UTC, deadalnix wrote: On Thursday, 23 June 2016 at 19:24:54 UTC, via Digitalmars-d wrote: On Thu, Jun 23, 2016 at 07:11:26PM +,

Re: Please rid me of this goto

2016-06-24 Thread deadalnix via Digitalmars-d
On Friday, 24 June 2016 at 08:40:26 UTC, Patrick Schluter wrote: On Thursday, 23 June 2016 at 20:01:26 UTC, deadalnix wrote: On Thursday, 23 June 2016 at 19:24:54 UTC, via Digitalmars-d wrote: On Thu, Jun 23, 2016 at 07:11:26PM +, deadalnix via Digitalmars-d wrote: | is bitwize or. || is

Re: Please rid me of this goto

2016-06-24 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 24 June 2016 at 09:04:55 UTC, Ola Fosheim Grøstad wrote: Inf^-1 = 0.0 Inf^0 = 1.0 Inf^1 = Inf :-) Or actually: NaN^-epsilon = Nan Nan^0 = 1.0 NaN^epsilon = Nan Inf^-epsilon = 0.0 Inf^0 = 1.0 Inf^epsilon = Inf It is rather difficult to argue that this is reasonable...

Re: Please rid me of this goto

2016-06-24 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 24 June 2016 at 06:58:14 UTC, Martin Tschierschke wrote: On Thursday, 23 June 2016 at 23:18:03 UTC, H. S. Teoh wrote: On Thu, Jun 23, 2016 at 11:14:08PM +, deadalnix via Digitalmars-d wrote: On Thursday, 23 June 2016 at 22:53:59 UTC, H. S. Teoh wrote: > This argument only works

Re: Please rid me of this goto

2016-06-24 Thread Patrick Schluter via Digitalmars-d
On Thursday, 23 June 2016 at 20:01:26 UTC, deadalnix wrote: On Thursday, 23 June 2016 at 19:24:54 UTC, via Digitalmars-d wrote: On Thu, Jun 23, 2016 at 07:11:26PM +, deadalnix via Digitalmars-d wrote: | is bitwize or. || is binary or. & is bitwize and. && is binary and. ^ is bitwize xor.

Re: Please rid me of this goto

2016-06-24 Thread deadalnix via Digitalmars-d
On Thursday, 23 June 2016 at 23:18:03 UTC, H. S. Teoh wrote: On Thu, Jun 23, 2016 at 11:14:08PM +, deadalnix via Digitalmars-d wrote: On Thursday, 23 June 2016 at 22:53:59 UTC, H. S. Teoh wrote: > This argument only works for discrete sets. If n and m are > reals, you'd need a different

Re: Please rid me of this goto

2016-06-24 Thread Martin Tschierschke via Digitalmars-d
On Thursday, 23 June 2016 at 23:18:03 UTC, H. S. Teoh wrote: On Thu, Jun 23, 2016 at 11:14:08PM +, deadalnix via Digitalmars-d wrote: On Thursday, 23 June 2016 at 22:53:59 UTC, H. S. Teoh wrote: > This argument only works for discrete sets. If n and m are > reals, you'd need a different

Re: Please rid me of this goto

2016-06-24 Thread H. S. Teoh via Digitalmars-d
On Fri, Jun 24, 2016 at 05:22:11AM +0200, Timon Gehr via Digitalmars-d wrote: [...] > (BTW: It would be fine with me if 0.0^^0.0 was NaN -- that's a > completely different case than the one at hand: pow on integers.) That's even worse. So 0^0=1 if 0 is regarded as an integer, and 0^0=NaN if 0 is

Re: Please rid me of this goto

2016-06-23 Thread Timon Gehr via Digitalmars-d
On 24.06.2016 05:22, Timon Gehr wrote: ... break the laws of physics by arbitrarily defining something to be true when it is not. ... Utter nonsense. (Also note that the 'laws of physics' typically give rise to piecewise analytic functions, and if you only consider analytic functions, 0 ^ 0

Re: Please rid me of this goto

2016-06-23 Thread Timon Gehr via Digitalmars-d
On 24.06.2016 04:36, Smoke Adams wrote: You do realize that e^(-1/t)^t is a counter example? e^(-1/t) -> 0 as t -> 0 t -> 0 as t -> 0 That's not a counterexample to anything I said. ^ is discontinuous at (0,0) and indeed, you can force the limit to an arbitrary value by choosing

Re: Please rid me of this goto

2016-06-23 Thread Smoke Adams via Digitalmars-d
On Friday, 24 June 2016 at 01:49:27 UTC, Timon Gehr wrote: On 24.06.2016 02:14, H. S. Teoh via Digitalmars-d wrote: On Fri, Jun 24, 2016 at 01:58:01AM +0200, Timon Gehr via Digitalmars-d wrote: On 24.06.2016 01:18, H. S. Teoh via Digitalmars-d wrote: On Thu, Jun 23, 2016 at 11:14:08PM +,

Re: Please rid me of this goto

2016-06-23 Thread Timon Gehr via Digitalmars-d
On 24.06.2016 02:14, H. S. Teoh via Digitalmars-d wrote: On Fri, Jun 24, 2016 at 01:58:01AM +0200, Timon Gehr via Digitalmars-d wrote: On 24.06.2016 01:18, H. S. Teoh via Digitalmars-d wrote: On Thu, Jun 23, 2016 at 11:14:08PM +, deadalnix via Digitalmars-d wrote: On Thursday, 23 June

Re: Please rid me of this goto

2016-06-23 Thread David Nadlinger via Digitalmars-d
On Friday, 24 June 2016 at 00:26:52 UTC, John Colvin wrote: My biggest bugbear is actually the opposite of what you are point out here: people doing careful benchmarking and asm-inspection of small code-fragments in isolation when in reality it is always going to be inlined and optimised in

Re: Please rid me of this goto

2016-06-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 June 2016 at 23:34:54 UTC, David Nadlinger wrote: On Thursday, 23 June 2016 at 22:08:20 UTC, Seb wrote: [1] https://github.com/wilzbach/perf-d/blob/master/test_pow.d [2] https://github.com/wilzbach/perf-d/blob/master/test_powi.d This is a bad way to benchmark. You are

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Fri, Jun 24, 2016 at 01:58:01AM +0200, Timon Gehr via Digitalmars-d wrote: > On 24.06.2016 01:18, H. S. Teoh via Digitalmars-d wrote: > > On Thu, Jun 23, 2016 at 11:14:08PM +, deadalnix via Digitalmars-d wrote: > > > On Thursday, 23 June 2016 at 22:53:59 UTC, H. S. Teoh wrote: > > > > This

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Fri, Jun 24, 2016 at 01:33:46AM +0200, Timon Gehr via Digitalmars-d wrote: > On 24.06.2016 00:53, H. S. Teoh via Digitalmars-d wrote: > > > >Because 0^^0 = 1, and 1 is representable. > > > > > > > >E.g. n^^m counts the number of functions from an m-set to an n-set, > > > >and there is exactly

Re: Please rid me of this goto

2016-06-23 Thread Timon Gehr via Digitalmars-d
On 24.06.2016 01:18, H. S. Teoh via Digitalmars-d wrote: On Thu, Jun 23, 2016 at 11:14:08PM +, deadalnix via Digitalmars-d wrote: On Thursday, 23 June 2016 at 22:53:59 UTC, H. S. Teoh wrote: This argument only works for discrete sets. If n and m are reals, you'd need a different argument.

Re: Please rid me of this goto

2016-06-23 Thread David Nadlinger via Digitalmars-d
On Thursday, 23 June 2016 at 23:34:54 UTC, David Nadlinger wrote: I get the following results: (This is of course not intended to be a comprehensive analysis. For example, the codegen for the two functions is actually identical on GDC and LDC, the relative differences are due to measurement

Re: Please rid me of this goto

2016-06-23 Thread David Nadlinger via Digitalmars-d
On Thursday, 23 June 2016 at 22:08:20 UTC, Seb wrote: [1] https://github.com/wilzbach/perf-d/blob/master/test_pow.d [2] https://github.com/wilzbach/perf-d/blob/master/test_powi.d This is a bad way to benchmark. You are essentially testing the compiler's ability to propagate your constants

Re: Please rid me of this goto

2016-06-23 Thread Timon Gehr via Digitalmars-d
On 24.06.2016 00:53, H. S. Teoh via Digitalmars-d wrote: >Because 0^^0 = 1, and 1 is representable. > >E.g. n^^m counts the number of functions from an m-set to an n-set, >and there is exactly one function from {} to {}. This argument only works for discrete sets. No, it works for any

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Thu, Jun 23, 2016 at 11:14:08PM +, deadalnix via Digitalmars-d wrote: > On Thursday, 23 June 2016 at 22:53:59 UTC, H. S. Teoh wrote: > > This argument only works for discrete sets. If n and m are reals, > > you'd need a different argument. > > > > For reals, you can use

Re: Please rid me of this goto

2016-06-23 Thread deadalnix via Digitalmars-d
On Thursday, 23 June 2016 at 22:53:59 UTC, H. S. Teoh wrote: This argument only works for discrete sets. If n and m are reals, you'd need a different argument. For reals, you can use limits/continuation as argument.

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Thu, Jun 23, 2016 at 11:30:51PM +0200, Timon Gehr via Digitalmars-d wrote: > On 23.06.2016 23:04, Andrei Alexandrescu wrote: > > On 06/23/2016 02:59 PM, Timon Gehr wrote: > > > On 23.06.2016 19:22, Andrei Alexandrescu wrote: > > > > So I was looking for an efficient exponentiation

Re: Please rid me of this goto

2016-06-23 Thread deadalnix via Digitalmars-d
Can you post codegen for each ?

Re: Please rid me of this goto

2016-06-23 Thread Seb via Digitalmars-d
On Thursday, 23 June 2016 at 21:03:08 UTC, Andrei Alexandrescu wrote: On 06/23/2016 02:37 PM, Seb wrote: On Thursday, 23 June 2016 at 18:05:07 UTC, Andrei Alexandrescu wrote: On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote: I don't understand why that goto is necessary. Eh, thank

Re: Please rid me of this goto

2016-06-23 Thread Timon Gehr via Digitalmars-d
On 23.06.2016 23:04, Andrei Alexandrescu wrote: On 06/23/2016 02:59 PM, Timon Gehr wrote: On 23.06.2016 19:22, Andrei Alexandrescu wrote: So I was looking for an efficient exponentiation implementation, and http://www.stepanovpapers.com/PAM.pdf has a nice discussion starting at page 54.

Re: Please rid me of this goto

2016-06-23 Thread deadalnix via Digitalmars-d
On Thursday, 23 June 2016 at 21:03:08 UTC, Andrei Alexandrescu wrote: However you should test how it performs against the LLVM intrinsics available in LDC, e.g.: llvm.intrinsincs.llvm_pow and llvm_powi (i = integer). Cool! Is that a CPU operation? Andrei It is going to depend on the

Re: Please rid me of this goto

2016-06-23 Thread Walter Bright via Digitalmars-d
On 6/23/2016 10:22 AM, Andrei Alexandrescu wrote: https://dpaste.dzfl.pl/e53acb41885a Paste bin links are ephemeral. The code from the link: /** */ int pow(int lhs, uint rhs, ref bool overflow) { return powImpl(lhs, rhs, overflow); } /// ditto long pow(long lhs, uint rhs, ref bool overflow) {

Re: Please rid me of this goto

2016-06-23 Thread Andrei Alexandrescu via Digitalmars-d
On 06/23/2016 02:59 PM, Timon Gehr wrote: On 23.06.2016 19:22, Andrei Alexandrescu wrote: So I was looking for an efficient exponentiation implementation, and http://www.stepanovpapers.com/PAM.pdf has a nice discussion starting at page 54. Stepanov's solution, however, duplicates code, so I

Re: Please rid me of this goto

2016-06-23 Thread Andrei Alexandrescu via Digitalmars-d
On 06/23/2016 02:37 PM, Seb wrote: On Thursday, 23 June 2016 at 18:05:07 UTC, Andrei Alexandrescu wrote: On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote: I don't understand why that goto is necessary. Eh, thank you all who set me straight! I've been in my head for too long. So

Re: Please rid me of this goto

2016-06-23 Thread deadalnix via Digitalmars-d
On Thursday, 23 June 2016 at 19:24:54 UTC, via Digitalmars-d wrote: On Thu, Jun 23, 2016 at 07:11:26PM +, deadalnix via Digitalmars-d wrote: | is bitwize or. || is binary or. & is bitwize and. && is binary and. ^ is bitwize xor. ^^ is... no, never mind. binary xor is != lol 3 != 5

Re: Please rid me of this goto

2016-06-23 Thread via Digitalmars-d
On Thu, Jun 23, 2016 at 07:11:26PM +, deadalnix via Digitalmars-d wrote: > | is bitwize or. || is binary or. > & is bitwize and. && is binary and. > ^ is bitwize xor. ^^ is... no, never mind. binary xor is != lol

Re: Please rid me of this goto

2016-06-23 Thread deadalnix via Digitalmars-d
On Thursday, 23 June 2016 at 18:49:56 UTC, ketmar wrote: On Thursday, 23 June 2016 at 18:35:23 UTC, jmh530 wrote: You're thinking of pow in std.math. I don't see opBinary!("^^") anywhere in there. I only see ^^ in comments. the "^^" is very special, 'cause it is the one and only thing that

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Thu, Jun 23, 2016 at 08:59:07PM +0200, Timon Gehr via Digitalmars-d wrote: [...] > Unrelated comment: 0^^0 should not overflow. Says who?

Re: Please rid me of this goto

2016-06-23 Thread Timon Gehr via Digitalmars-d
On 23.06.2016 19:22, Andrei Alexandrescu wrote: So I was looking for an efficient exponentiation implementation, and http://www.stepanovpapers.com/PAM.pdf has a nice discussion starting at page 54. Stepanov's solution, however, duplicates code, so I eliminated it:

Re: Please rid me of this goto

2016-06-23 Thread ketmar via Digitalmars-d
On Thursday, 23 June 2016 at 18:35:23 UTC, jmh530 wrote: You're thinking of pow in std.math. I don't see opBinary!("^^") anywhere in there. I only see ^^ in comments. the "^^" is very special, 'cause it is the one and only thing that compiler recognizes as "function call" in expression

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Thu, Jun 23, 2016 at 06:35:23PM +, jmh530 via Digitalmars-d wrote: > On Thursday, 23 June 2016 at 18:20:00 UTC, H. S. Teoh wrote: > > On Thu, Jun 23, 2016 at 02:05:07PM -0400, Andrei Alexandrescu via > > Digitalmars-d wrote: > > > On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote:

Re: Please rid me of this goto

2016-06-23 Thread Seb via Digitalmars-d
On Thursday, 23 June 2016 at 18:05:07 UTC, Andrei Alexandrescu wrote: On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote: I don't understand why that goto is necessary. Eh, thank you all who set me straight! I've been in my head for too long. So where is the current implementation of

Re: Please rid me of this goto

2016-06-23 Thread jmh530 via Digitalmars-d
On Thursday, 23 June 2016 at 18:20:00 UTC, H. S. Teoh wrote: On Thu, Jun 23, 2016 at 02:05:07PM -0400, Andrei Alexandrescu via Digitalmars-d wrote: On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote: > I don't understand why that goto is necessary. Eh, thank you all who set me

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Thu, Jun 23, 2016 at 02:05:07PM -0400, Andrei Alexandrescu via Digitalmars-d wrote: > On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote: > > I don't understand why that goto is necessary. > > Eh, thank you all who set me straight! I've been in my head for too > long. So where is the

Re: Please rid me of this goto

2016-06-23 Thread Stefan Koch via Digitalmars-d
On Thursday, 23 June 2016 at 18:05:07 UTC, Andrei Alexandrescu wrote: On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote: I don't understand why that goto is necessary. Eh, thank you all who set me straight! I've been in my head for too long. So where is the current implementation of

Re: Please rid me of this goto

2016-06-23 Thread Andrei Alexandrescu via Digitalmars-d
On 06/23/2016 01:34 PM, H. S. Teoh via Digitalmars-d wrote: I don't understand why that goto is necessary. Eh, thank you all who set me straight! I've been in my head for too long. So where is the current implementation of "^^"? If it's not as fast as this, we should replace it. -- Andrei

Re: Please rid me of this goto

2016-06-23 Thread deadalnix via Digitalmars-d
On Thursday, 23 June 2016 at 17:22:55 UTC, Andrei Alexandrescu wrote: So I was looking for an efficient exponentiation implementation, and http://www.stepanovpapers.com/PAM.pdf has a nice discussion starting at page 54. Stepanov's solution, however, duplicates code, so I eliminated it:

Re: Please rid me of this goto

2016-06-23 Thread Steven Schveighoffer via Digitalmars-d
On 6/23/16 1:22 PM, Andrei Alexandrescu wrote: So I was looking for an efficient exponentiation implementation, and http://www.stepanovpapers.com/PAM.pdf has a nice discussion starting at page 54. Stepanov's solution, however, duplicates code, so I eliminated it:

Re: Please rid me of this goto

2016-06-23 Thread Kagamin via Digitalmars-d
// Loop invariant: r * (b ^^ e) is the actual result for (;;) { if (e % 2 != 0) { r = mul(r, b, overflow); if (e == 1) return r; } b = mul(b, b, overflow); e /= 2; } ?

Re: Please rid me of this goto

2016-06-23 Thread H. S. Teoh via Digitalmars-d
On Thu, Jun 23, 2016 at 01:22:55PM -0400, Andrei Alexandrescu via Digitalmars-d wrote: > So I was looking for an efficient exponentiation implementation, and > http://www.stepanovpapers.com/PAM.pdf has a nice discussion starting > at page 54. Stepanov's solution, however, duplicates code, so I >

Please rid me of this goto

2016-06-23 Thread Andrei Alexandrescu via Digitalmars-d
So I was looking for an efficient exponentiation implementation, and http://www.stepanovpapers.com/PAM.pdf has a nice discussion starting at page 54. Stepanov's solution, however, duplicates code, so I eliminated it: https://dpaste.dzfl.pl/e53acb41885a The cost is the use of one goto. Can the