digitalmars.D - Octal-like integer literals
- H. S. Teoh (11/11) Feb 11 2012 Alright, I'm plodding along slowly with my D lexer, and I'm running into
- Daniel Murphy (4/15) Feb 11 2012 As an error. Because they're allowed in C/C++/etc having them accepted ...
- Ellery Newcomer (2/3) Feb 11 2012
- Timon Gehr (3/12) Feb 11 2012 Octal literals whose value is larger than 7 must be rejected. Octal
- H. S. Teoh (8/22) Feb 11 2012 Are we still supporting octal literals? They are scheduled to be removed
- Andrej Mitrovic (2/2) Feb 11 2012 Octals are going away, the use of them in Phobos have been removed and
- H. S. Teoh (6/8) Feb 11 2012 So the question is, how will things like "0744" and "098" be interpreted
- Timon Gehr (2/8) Feb 11 2012 Probably yes, except for '0+[1-7]?'.
- Andrej Mitrovic (9/14) Feb 11 2012 module test;
- Walter Bright (3/4) Feb 16 2012 And 0744 will never be valid D code, for the simple reason that code mov...
- Walter Bright (2/4) Feb 16 2012 I was inordinately proud of that error message :-)
- Daniel Murphy (7/12) Feb 16 2012 I had a look at moving them from deprecated to error, but druntime uses ...
- H. S. Teoh (3/16) Feb 16 2012 So why not make the octal template part of druntime?
Alright, I'm plodding along slowly with my D lexer, and I'm running into an interesting case. According to the spec, int literals that begin with '0' are supposed to be octal, with the exception of "0" itself, which is decimal 0. DecimalInteger is defined to begin with a non-zero digit followed by one or more digits (may be zero). So how should the lexer treat a literal like "0800" or "0900"? (Since octal literals are deprecated, I'm leaving them out of my lexer, so should 0800 and 0900 be rejected as invalid?) T -- Change is inevitable, except from a vending machine.
Feb 11 2012
As an error. Because they're allowed in C/C++/etc having them accepted by D but interpreted differently is just errors waiting to happen. "H. S. Teoh" <hsteoh quickfur.ath.cx> wrote in message news:mailman.230.1328975949.20196.digitalmars-d puremagic.com...Alright, I'm plodding along slowly with my D lexer, and I'm running into an interesting case. According to the spec, int literals that begin with '0' are supposed to be octal, with the exception of "0" itself, which is decimal 0. DecimalInteger is defined to begin with a non-zero digit followed by one or more digits (may be zero). So how should the lexer treat a literal like "0800" or "0900"? (Since octal literals are deprecated, I'm leaving them out of my lexer, so should 0800 and 0900 be rejected as invalid?) T -- Change is inevitable, except from a vending machine.
Feb 11 2012
OT: http://d.puremagic.com/issues/show_bug.cgi?id=5132 On 02/11/2012 10:06 AM, Daniel Murphy wrote:interpreted differently is just errors waiting to happen.
Feb 11 2012
On 02/11/2012 05:00 PM, H. S. Teoh wrote:Alright, I'm plodding along slowly with my D lexer, and I'm running into an interesting case. According to the spec, int literals that begin with '0' are supposed to be octal, with the exception of "0" itself, which is decimal 0. DecimalInteger is defined to begin with a non-zero digit followed by one or more digits (may be zero). So how should the lexer treat a literal like "0800" or "0900"? (Since octal literals are deprecated, I'm leaving them out of my lexer, so should 0800 and 0900 be rejected as invalid?) TOctal literals whose value is larger than 7 must be rejected. Octal literals with values up to 7 must be accepted.
Feb 11 2012
On Sat, Feb 11, 2012 at 05:37:17PM +0100, Timon Gehr wrote:On 02/11/2012 05:00 PM, H. S. Teoh wrote:[...]Alright, I'm plodding along slowly with my D lexer, and I'm running into an interesting case. According to the spec, int literals that begin with '0' are supposed to be octal, with the exception of "0" itself, which is decimal 0. DecimalInteger is defined to begin with a non-zero digit followed by one or more digits (may be zero). So how should the lexer treat a literal like "0800" or "0900"? (Since octal literals are deprecated, I'm leaving them out of my lexer, so should 0800 and 0900 be rejected as invalid?)Octal literals whose value is larger than 7 must be rejected. Octal literals with values up to 7 must be accepted.Are we still supporting octal literals? They are scheduled to be removed at some point, right? FWIW the online specs have no reference to octal literals although the definitions of octal digits are still there. T -- There's light at the end of the tunnel. It's the oncoming train.
Feb 11 2012
Octals are going away, the use of them in Phobos have been removed and Walter confirmed this too afaik.
Feb 11 2012
On Sat, Feb 11, 2012 at 06:48:20PM +0100, Andrej Mitrovic wrote:Octals are going away, the use of them in Phobos have been removed and Walter confirmed this too afaik.So the question is, how will things like "0744" and "098" be interpreted once octals have gone away? Will they still be rejected by the compiler? T -- Talk is cheap. Whining is actually free. -- Lars Wirzenius
Feb 11 2012
On 02/11/2012 07:05 PM, H. S. Teoh wrote:On Sat, Feb 11, 2012 at 06:48:20PM +0100, Andrej Mitrovic wrote:Probably yes, except for '0+[1-7]?'.Octals are going away, the use of them in Phobos have been removed and Walter confirmed this too afaik.So the question is, how will things like "0744" and "098" be interpreted once octals have gone away? Will they still be rejected by the compiler? T
Feb 11 2012
On 2/11/12, H. S. Teoh <hsteoh quickfur.ath.cx> wrote:On Sat, Feb 11, 2012 at 06:48:20PM +0100, Andrej Mitrovic wrote:module test; void main() { auto x = 0744; } $ dmd test.d $ test.d(5): octal literals 0744 are deprecated, use std.conv.octal!744 instead You can only use them with the -d switch.Octals are going away, the use of them in Phobos have been removed and Walter confirmed this too afaik.So the question is, how will things like "0744" and "098" be interpreted once octals have gone away? Will they still be rejected by the compiler?
Feb 11 2012
On 2/11/2012 10:43 AM, Andrej Mitrovic wrote:You can only use them with the -d switch.And 0744 will never be valid D code, for the simple reason that code moved over from C would silently break in awful ways.
Feb 16 2012
On 2/11/2012 10:43 AM, Andrej Mitrovic wrote:$ dmd test.d $ test.d(5): octal literals 0744 are deprecated, use std.conv.octal!744 insteadI was inordinately proud of that error message :-)
Feb 16 2012
I had a look at moving them from deprecated to error, but druntime uses them extensively in the os headers. I think we need a better solution than a template in the standard library - you shouldn't need a dependency on phobos to use them, and the compiler shouldn't directly reference anything in the standard library. "Walter Bright" <newshound2 digitalmars.com> wrote in message news:jhkqsj$30j$2 digitalmars.com...On 2/11/2012 10:43 AM, Andrej Mitrovic wrote:$ dmd test.d $ test.d(5): octal literals 0744 are deprecated, use std.conv.octal!744 insteadI was inordinately proud of that error message :-)
Feb 16 2012
On Fri, Feb 17, 2012 at 05:17:00PM +1100, Daniel Murphy wrote:I had a look at moving them from deprecated to error, but druntime uses them extensively in the os headers. I think we need a better solution than a template in the standard library - you shouldn't need a dependency on phobos to use them, and the compiler shouldn't directly reference anything in the standard library.So why not make the octal template part of druntime? --T"Walter Bright" <newshound2 digitalmars.com> wrote in message news:jhkqsj$30j$2 digitalmars.com...On 2/11/2012 10:43 AM, Andrej Mitrovic wrote:$ dmd test.d $ test.d(5): octal literals 0744 are deprecated, use std.conv.octal!744 insteadI was inordinately proud of that error message :-)
Feb 16 2012