Re: Apparently unsigned types really are necessary

2012-01-24 Thread Steven Schveighoffer
On Sun, 22 Jan 2012 23:38:24 -0500, Kagamin s...@here.lot wrote: On Sunday, 22 January 2012 at 22:17:10 UTC, Marco Leise wrote: If you ignore type limits, you're asking for trouble. Imagine you have 2 gigs of ram and 3 gig pagefile on 32-bit OS. What is the total size of available memory?

Re: Apparently unsigned types really are necessary

2012-01-23 Thread Marco Leise
Am 23.01.2012, 00:22 Uhr, schrieb Era Scarecrow rtcv...@yahoo.com: Points: 1) that 2nd formatting still includes whitespace that would be illegal (e.g. every place but between 'void' and 'print' and in the strings litereals). 2) The *point* is to turn code into an unreadable mash on a single

Re: Apparently unsigned types really are necessary

2012-01-23 Thread Nick Sabalausky
bcs b...@example.com wrote in message news:jfhqgv$13f7$1...@digitalmars.com... On 01/22/2012 10:09 AM, Walter Bright wrote: On 1/22/2012 4:40 AM, Marco Leise wrote: Or is this like spaces vs. tabs? 'Cause I'm also a tab user. I struggled with that for years. Not with my own code, the tabs

Re: Apparently unsigned types really are necessary

2012-01-23 Thread Nick Sabalausky
Walter Bright newshou...@digitalmars.com wrote in message news:jfhjd6$lgf$1...@digitalmars.com... On 1/22/2012 4:40 AM, Marco Leise wrote: Or is this like spaces vs. tabs? 'Cause I'm also a tab user. The dirty rotten spacies can pry the tabs from my cold dead hands ;) I struggled with that

Re: Apparently unsigned types really are necessary

2012-01-23 Thread Era Scarecrow
From: Nick Sabalausky a@a.a ''' White space may consist of: - A comment between any two tokens. - A single space between tokens that, if adjoined would be a single token. All other white space (including \n \r \t \v, etc.) is forbidden and a lexical error. ''' With these

Re: Apparently unsigned types really are necessary

2012-01-23 Thread bcs
On 01/23/2012 07:13 PM, Era Scarecrow wrote: From: Nick Sabalauskya@a.a ''' White space may consist of: - A comment between any two tokens. - A single space between tokens that, if adjoined would be a single token. All other white space (including \n \r \t \v, etc.) is forbidden and a

Re: Apparently unsigned types really are necessary

2012-01-23 Thread bcs
On 01/23/2012 02:11 AM, Marco Leise wrote: Am 23.01.2012, 00:22 Uhr, schrieb Era Scarecrow rtcv...@yahoo.com: Points: 1) that 2nd formatting still includes whitespace that would be illegal (e.g. every place but between 'void' and 'print' and in the strings litereals). 2) The *point* is to

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Marco Leise
Am 22.01.2012, 08:23 Uhr, schrieb bcs b...@example.com: On 01/21/2012 10:05 PM, Walter Bright wrote: http://news.ycombinator.com/item?id=3495283 and getting rid of unsigned types is not the solution to signed/unsigned issues. A quote from that link: There are many use cases for data types

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Mail Mantis
2012/1/22 Walter Bright newshou...@digitalmars.com: http://news.ycombinator.com/item?id=3495283 and getting rid of unsigned types is not the solution to signed/unsigned issues. Would it be sane to add integer overflow/carry runtime checks in -debug builds? This could probably solve such

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Jonathan M Davis
On Sunday, January 22, 2012 10:31:17 Marco Leise wrote: Am 22.01.2012, 08:23 Uhr, schrieb bcs b...@example.com: Rename them bits{8,16,32,64} and make the current names aliases. So everyone uses int, and we get messages like: This program currently uses -1404024 bytes of RAM. I have strong

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Walter Bright
On 1/22/2012 1:44 AM, Jonathan M Davis wrote: Whereas others have string feelings Sometimes I feel like a hashmap.

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Jonathan M Davis
On Sunday, January 22, 2012 01:49:02 Walter Bright wrote: On 1/22/2012 1:44 AM, Jonathan M Davis wrote: Whereas others have string feelings Sometimes I feel like a hashmap. LOL. I keep forgetting to reread my posts before I post them. I really should fix that... - Jonathan M Davis

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Era Scarecrow
Would it be sane to add integer overflow/carry runtime checks in -debug builds? This could probably solve such issues, but we'd need some means to avoid this checks when necessary. I have asked before regarding getting some standard way to hold these values after an arithmetic operation.

Re: Apparently unsigned types really are necessary

2012-01-22 Thread bearophile
Era Scarecrow: We would need a way to specify which ints needed to be checked; Or if you want to go the other direction, specify which ones specifically don't. I think having the checks in the debug mode would be wonderful, for when you need it. If D will have some success, and it will

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Marco Leise
Am 22.01.2012, 10:44 Uhr, schrieb Jonathan M Davis jmdavisp...@gmx.com: On Sunday, January 22, 2012 10:31:17 Marco Leise wrote: Am 22.01.2012, 08:23 Uhr, schrieb bcs b...@example.com: Rename them bits{8,16,32,64} and make the current names aliases. So everyone uses int, and we get messages

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Jonathan M Davis
On Sunday, January 22, 2012 13:40:08 Marco Leise wrote: I heard that in the past, but in my own experience using unsigned data types, it did not cause any more bugs. OTOH, textual output is more correct and I find code easier to understand, if it is using the correct 'class' of integers. But

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Mail Mantis
2012/1/22 Jonathan M Davis jmdavisp...@gmx.com: Another potentially nasty situation is subtraction. It can do fun things when you subtract one unsigned type from another if you're not careful... It is unrelated to unsigned types in any way, isn't it?: int a = 2_000_000_000; assert( a + a ==

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Andrei Alexandrescu
On 1/22/12 3:44 AM, Jonathan M Davis wrote: Whereas others have string feelings about using unsigned types My feelings in the matter are definitely integral. Andrei

Re: Apparently unsigned types really are necessary

2012-01-22 Thread torhu
On 22.01.2012 13:49, Jonathan M Davis wrote: On Sunday, January 22, 2012 13:40:08 Marco Leise wrote: I heard that in the past, but in my own experience using unsigned data types, it did not cause any more bugs. OTOH, textual output is more correct and I find code easier to understand, if it

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Martin Nowak
On Sun, 22 Jan 2012 13:49:37 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: One issue with unsigned integers right off the bat is for loops. for(size_t i = a.length; i 0; --i) {} is not going to work. What's not working with this? Besides a neat idiom for reverse array indexing

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Marco Leise
Am 22.01.2012, 13:49 Uhr, schrieb Jonathan M Davis jmdavisp...@gmx.com: Down with tabs! ;) One issue with unsigned integers right off the bat is for loops. for(size_t i = a.length; i 0; --i) {} is not going to work. That is C style. In D you would write: foreach_reverse(i; 0 .. a.length)

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Ali Çehreli
On 01/22/2012 04:49 AM, Jonathan M Davis wrote: Another potentially nasty situation is subtraction. It can do fun things when you subtract one unsigned type from another if you're not careful (since if the result is negative and is then assigned to an unsigned integer...). No need to

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Marco Leise
Am 22.01.2012, 18:00 Uhr, schrieb Ali Çehreli acehr...@yahoo.com: On 01/22/2012 04:49 AM, Jonathan M Davis wrote: Another potentially nasty situation is subtraction. It can do fun things when you subtract one unsigned type from another if you're not careful (since if the result is

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Walter Bright
On 1/22/2012 4:40 AM, Marco Leise wrote: Or is this like spaces vs. tabs? 'Cause I'm also a tab user. I struggled with that for years. Not with my own code, the tabs worked fine. The trouble was when collaborating with other people, who insisted on using tab stop settings that were the evil

Re: Apparently unsigned types really are necessary

2012-01-22 Thread bcs
On 01/22/2012 01:31 AM, Marco Leise wrote: Am 22.01.2012, 08:23 Uhr, schrieb bcs b...@example.com: On 01/21/2012 10:05 PM, Walter Bright wrote: http://news.ycombinator.com/item?id=3495283 and getting rid of unsigned types is not the solution to signed/unsigned issues. A quote from that

Re: Apparently unsigned types really are necessary

2012-01-22 Thread bcs
On 01/22/2012 10:09 AM, Walter Bright wrote: On 1/22/2012 4:40 AM, Marco Leise wrote: Or is this like spaces vs. tabs? 'Cause I'm also a tab user. I struggled with that for years. Not with my own code, the tabs worked fine. The trouble was when collaborating with other people, who insisted on

Re: Apparently unsigned types really are necessary

2012-01-22 Thread bcs
On 01/22/2012 01:42 AM, Mail Mantis wrote: 2012/1/22 Walter Brightnewshou...@digitalmars.com: http://news.ycombinator.com/item?id=3495283 and getting rid of unsigned types is not the solution to signed/unsigned issues. Would it be sane to add integer overflow/carry runtime checks in -debug

Re: Apparently unsigned types really are necessary

2012-01-22 Thread foobar
On Sunday, 22 January 2012 at 20:01:52 UTC, bcs wrote: On 01/22/2012 01:31 AM, Marco Leise wrote: Am 22.01.2012, 08:23 Uhr, schrieb bcs b...@example.com: On 01/21/2012 10:05 PM, Walter Bright wrote: http://news.ycombinator.com/item?id=3495283 and getting rid of unsigned types is not the

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Kagamin
On Sunday, 22 January 2012 at 09:31:15 UTC, Marco Leise wrote: So everyone uses int, and we get messages like: This program currently uses -1404024 bytes of RAM. I have strong feelings against using signed types for variables that are ever going to only hold positive numbers, especially when

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Nick Sabalausky
Kagamin s...@here.lot wrote in message news:bhhmhjvgsmlxjvsuw...@dfeed.kimsufi.thecybershadow.net... On Sunday, 22 January 2012 at 09:31:15 UTC, Marco Leise wrote: So everyone uses int, and we get messages like: This program currently uses -1404024 bytes of RAM. I have strong feelings against

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Era Scarecrow
My I propose the following modifications to the D lexer: ''' White space may consist of: - A comment between any two tokens. - A single space between tokens that, if adjoined would be a single token. All other white space (including \n \r \t \v, etc.) is forbidden and a lexical error.

Re: Apparently unsigned types really are necessary

2012-01-22 Thread bcs
On 01/22/2012 01:24 PM, Era Scarecrow wrote: My I propose the following modifications to the D lexer: ''' White space may consist of: - A comment between any two tokens. - A single space between tokens that, if adjoined would be a single token. All other white space (including \n \r \t \v,

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Marco Leise
Am 22.01.2012, 21:44 Uhr, schrieb Kagamin s...@here.lot: On Sunday, 22 January 2012 at 09:31:15 UTC, Marco Leise wrote: So everyone uses int, and we get messages like: This program currently uses -1404024 bytes of RAM. I have strong feelings against using signed types for variables that are

Re: Apparently unsigned types really are necessary

2012-01-22 Thread captaindet
On 2012-01-22 14:36, foobar wrote: On Sunday, 22 January 2012 at 20:01:52 UTC, bcs wrote: On 01/22/2012 01:31 AM, Marco Leise wrote: Am 22.01.2012, 08:23 Uhr, schrieb bcs b...@example.com: On 01/21/2012 10:05 PM, Walter Bright wrote: http://news.ycombinator.com/item?id=3495283 and getting

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Era Scarecrow
Points: 1) that 2nd formatting still includes whitespace that would be illegal (e.g. every place but between 'void' and 'print' and in the strings litereals). 2) The *point* is to turn code into an unreadable mash on a single line. 3) The entire proposal is satire. Ahh, i had the

Re: Apparently unsigned types really are necessary

2012-01-22 Thread Kagamin
On Sunday, 22 January 2012 at 22:17:10 UTC, Marco Leise wrote: If you ignore type limits, you're asking for trouble. Imagine you have 2 gigs of ram and 3 gig pagefile on 32-bit OS. What is the total size of available memory? I can use up to 4GB of that in the address space of my application

Apparently unsigned types really are necessary

2012-01-21 Thread Walter Bright
http://news.ycombinator.com/item?id=3495283 and getting rid of unsigned types is not the solution to signed/unsigned issues.

Re: Apparently unsigned types really are necessary

2012-01-21 Thread bcs
On 01/21/2012 10:05 PM, Walter Bright wrote: http://news.ycombinator.com/item?id=3495283 and getting rid of unsigned types is not the solution to signed/unsigned issues. A quote from that link: There are many use cases for data types that behave like pure bit strings with no concept of