November 21, 2014
On 11/21/2014 1:01 AM, Matthias Bentrup wrote:
> C# has the checked and unchecked operators
> (http://msdn.microsoft.com/en-us/library/khy08726.aspx), which allow the
> programmer to specify if overflows should wrap of fail within an arithmetic
> expression. That could be a useful addition to D.

D already has them:

https://github.com/D-Programming-Language/druntime/blob/master/src/core/checkedint.d

November 21, 2014
On 11/21/2014 12:16 AM, Daniel Murphy wrote:
> Over the years most of my unsigned-related bugs have been from screwing up
> various loop conditions.  Thankfully D solves this perfectly with:
>
> void fun(int[] a)
> {
>     foreach_reverse(i, 0...a.length)
>     {
>     }
> }
>
> So I never have to write those again.

I thought everyone hated foreach_reverse!

But, yeah, foreach and ranges+algorithms have virtually eliminated a large category of looping bugs.
November 21, 2014
On Thursday, 20 November 2014 at 16:34:12 UTC, flamencofantasy wrote:
> My experience is totally the opposite of his. I have been using unsigned for lengths, widths, heights for the past 15 years in C, C++, C# and more recently in D with great success. I don't pretend to be any kind of authority though.

C# doesn't encourage usage of unsigned types and warns that they are not CLS-compliant. You're going against established practices there. And signed types for numbers works wonders in C# without any notable problem and makes reasoning about code easier as you don't have to manually check for unsigned conversion bugs everywhere.

> The article you point to is totally flawed and kinda wasteful in terms of having to read it; the very first code snippet is obviously buggy.

That's the whole point: mixing signed with unsigned is bug-prone. Worse, it's inevitable if you force unsigned types everywhere.
November 21, 2014
On Friday, 21 November 2014 at 09:37:50 UTC, Walter Bright wrote:
> I thought everyone hated foreach_reverse!

I dislike foreach_reverse;
1. it's a keyword with an underscore in it;
2. complicates implementation of foreach and parsing.
3. key_word with under_score
November 21, 2014
"bearophile"  wrote in message news:rqyuiioyrrjgggctfpcx@forum.dlang.org...

> Better (it's a workaround for a D design flaw that we're unwilling to fix):
>
> foreach_reverse(immutable i, 0...a.length)
>

I know you feel that way, but I'd rather face the non-existent risk of accidentally mutating the induction variable than write immutable every time. 

November 21, 2014
> On Friday, 21 November 2014 at 09:37:50 UTC, Walter Bright wrote:
> > I thought everyone hated foreach_reverse!

Not me.  It's ugly but it gets the job done.  All I have to do is add '_reverse' and it just works!

"Stefan Koch"  wrote in message news:mmvuvkdfnvwezyvtcceq@forum.dlang.org...
> I dislike foreach_reverse;
> 1. it's a keyword with an underscore in it;

So what.

> 2. complicates implementation of foreach and parsing.

The additional complexity is trivial.

> 3. key_word with under_score

Don't care. 

November 21, 2014
"Frank Like"  wrote in message news:zhejapfebcvxnzrezcqj@forum.dlang.org...

> If this work is done in druntime,D will be a real system language.

Sure, this is obviously the fundamental thing holding D back from being a _real_ system language. 

November 21, 2014
Walter Bright:

> I thought everyone hated foreach_reverse!

I love it!

Bye,
bearophile
November 21, 2014
Daniel Murphy:

>> foreach_reverse(immutable i, 0...a.length)
>>
>
> I know you feel that way, but I'd rather face the non-existent risk of accidentally mutating the induction variable than write immutable every time.

It's not non-existent :-) (And the right default for a modern language is to have immutable on default and mutable on request. If D doesn't have this quality, better to add immutable every damn time).

Bye,
bearophile
November 21, 2014
On Friday, 21 November 2014 at 09:43:04 UTC, Kagamin wrote:
> On Thursday, 20 November 2014 at 16:34:12 UTC, flamencofantasy

> C# doesn't encourage usage of unsigned types and warns that they are not CLS-compliant. You're going against established practices there. And signed types for numbers works wonders in C# without any notable problem and makes reasoning about code easier as you don't have to manually check for unsigned conversion bugs everywhere.
>

> That's the whole point: mixing signed with unsigned is bug-prone. Worse, it's inevitable if you force unsigned types everywhere.

Right.

Druntime should have a checksize_t.d....


Frank