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
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 -
Should of course be:
int compare2(uint x, int y)
{
return (x > int.max) ? 1 : (cast(int)x - y);
}
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:
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
>
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,
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
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, $#
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
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
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
Of course without the ! after opCmp in the several cases.
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
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
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
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
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
>
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
18 matches
Mail list logo