Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-10 Thread JR via Digitalmars-d-learn
On Monday, 7 July 2014 at 23:47:26 UTC, Aerolite wrote: So, if you would be so kind, give me a bullet list of the aspects of D you believe to be good, awesome, bad, and/or ugly. If you have the time, some code examples wouldn't go amiss either! Try not to go in-depth to weird edge cases - remai

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-10 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
So at all the implementation will look something like this: int opCmp(T, U)(const(T) a, const(U) b) @primitive if(isIntegral!T && isIntegral!U) { alias CommonType!(Signed!T, Signed!U) C; static if(isSigned!T && isUnsigned!U) { return (b > cast(Unsigned!C)C.max) ? -1 : cast(C)a -

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-10 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
Should of course be: int compare2(uint x, int y) { return (x > int.max) ? 1 : (cast(int)x - y); }

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-10 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 19:54:47 UTC, H. S. Teoh via Digitalmars-d-learn wrote: [...] The problem is that the function needs to return int, but given two uints, their difference may be greater than int.max, so simply subtracting them will not work. So the best I can come up with is:

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 09, 2014 at 12:53:08PM -0700, H. S. Teoh via Digitalmars-d-learn wrote: [...] > (with gdc -O3 -funittest:) > > non-branching compare(signed,unsigned): 516 msecs > branching compare(signed,unsigned): 1209 msecs > non-branching compare(unsigned,signed): 453 msecs >

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 09, 2014 at 11:29:06AM -0700, H. S. Teoh via Digitalmars-d-learn wrote: > On Wed, Jul 09, 2014 at 05:43:15PM +, Dominikus Dittes Scherkl via > Digitalmars-d-learn wrote: > > On Wednesday, 9 July 2014 at 17:13:21 UTC, H. S. Teoh via > > Digitalmars-d-learn wrote: [...] > > >Often,

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 09, 2014 at 05:43:15PM +, Dominikus Dittes Scherkl via Digitalmars-d-learn wrote: > On Wednesday, 9 July 2014 at 17:13:21 UTC, H. S. Teoh via > Digitalmars-d-learn wrote: [..] > >Yeah, I don't see what's the problem with comparing signed and unsigned > >values, as long as the resul

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 17:13:21 UTC, H. S. Teoh via Digitalmars-d-learn wrote: The branched version would look something like this: mov eax, [] mov ebx, [] cmp ebx, $#0 jge label1 ; first branch mov eax, $#

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread anonymous via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 17:13:21 UTC, H. S. Teoh via Digitalmars-d-learn wrote: For the comparison s < u, where s is a signed value and u is an unsigned value, whenever s is negative, the return value of opCmp must be negative. Assuming 2's-complement representation of integers, this mean

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 17:13:21 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Jul 09, 2014 at 04:24:38PM +, Dominikus Dittes Scherkl via Digitalmars-d-learn wrote: /// Returns -1 if a < b, 0 if they are equal or 1 if a > b. /// this will always yield a correct result, no matte

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 09, 2014 at 04:24:38PM +, Dominikus Dittes Scherkl via Digitalmars-d-learn wrote: > On Wednesday, 9 July 2014 at 14:51:41 UTC, Meta wrote: > >One of the uglier things in D is also a long-standing problem with C > >and C++, in that comparison of signed and unsigned values is allowed

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
Of course without the ! after opCmp in the several cases.

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 14:51:41 UTC, Meta wrote: One of the uglier things in D is also a long-standing problem with C and C++, in that comparison of signed and unsigned values is allowed. I would like that, if it would be implemented along this line: /// Returns -1 if a < b, 0 if they a

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread Meta via Digitalmars-d-learn
On Monday, 7 July 2014 at 23:47:26 UTC, Aerolite wrote: Hey all, I've not posted here in a while, but I've been keeping up to speed with D's progress over the last couple of years and remain consistently impressed with the language. I'm part of a new computing society in the University of N

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-09 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 09, 2014 at 07:51:24AM +0200, Philippe Sigaud via Digitalmars-d-learn wrote: > On Tue, Jul 8, 2014 at 7:50 AM, H. S. Teoh via Digitalmars-d-learn > wrote > > Wow, what to add to that? Maybe you scared other from participating > ;-) I hope not. :) [...] > * I'd add static introspe

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-08 Thread Philippe Sigaud via Digitalmars-d-learn
On Tue, Jul 8, 2014 at 7:50 AM, H. S. Teoh via Digitalmars-d-learn wrote Wow, what to add to that? Maybe you scared other from participating ;-) * I'll second metaprogramming: the alliance between templates, CTFE and mixins is really nice. It's *the* feature (or triplet of features) I think of

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 07, 2014 at 11:47:25PM +, Aerolite via Digitalmars-d-learn wrote: [...] > So, if you would be so kind, give me a bullet list of the aspects of D > you believe to be good, awesome, bad, and/or ugly. If you have the > time, some code examples wouldn't go amiss either! Try not to go >

Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-07 Thread Aerolite via Digitalmars-d-learn
Hey all, I've not posted here in a while, but I've been keeping up to speed with D's progress over the last couple of years and remain consistently impressed with the language. I'm part of a new computing society in the University of Newcastle, Australia, and am essentially known throughout