Re: Octal Literals

2012-07-19 Thread Nick Sabalausky
lement it? Binary literals have been there since way back around the beginning of D, just like hex literals, decimal literals and the now-dead old-style octal literals. Back when *everything* in D was a new feature. If octal literals had been like 0o123 or 0c123 instead of 0123 from the beginning,

Re: Octal Literals

2012-07-19 Thread David Nadlinger
On Thursday, 19 July 2012 at 14:13:06 UTC, Dave X. wrote: How was the reception of the idea of binary literals as opposed to octal (I think it's an awesome feature, I think D, OCaml and Java 7 are the only ones that have it)? How long did it take to decide to implement it? If they were introd

Re: Octal Literals

2012-07-19 Thread Daniel Murphy
"Dave X." wrote in message news:cokspgduvpyzcbioa...@forum.dlang.org... > How was the reception of the idea of binary literals as opposed to octal > (I think it's an awesome feature, I think D, OCaml and Java 7 are the only > ones that have it)? How long did it take to decide to implement it?

Re: Octal Literals

2012-07-19 Thread Dave X.
How was the reception of the idea of binary literals as opposed to octal (I think it's an awesome feature, I think D, OCaml and Java 7 are the only ones that have it)? How long did it take to decide to implement it?

Re: Octal Literals

2012-07-19 Thread Daniel Murphy
have a lot of work. :) It's a trivial amount of work to add '0o' octal literals to the language, but it was decided that octals are not used often enough to justify a language feature.

Re: Octal Literals

2012-07-18 Thread Andrei Alexandrescu
On 7/18/12 1:39 PM, monarch_dodra wrote: On Wednesday, 18 July 2012 at 17:37:02 UTC, Andrei Alexandrescu wrote: On 7/18/12 10:29 AM, monarch_dodra wrote: I see no reason not to add it This is never a good argument for adding things to a language. Andrei Taken out of context, no it isn't. "

Re: Octal Literals

2012-07-18 Thread monarch_dodra
On Wednesday, 18 July 2012 at 17:37:02 UTC, Andrei Alexandrescu wrote: On 7/18/12 10:29 AM, monarch_dodra wrote: I see no reason not to add it This is never a good argument for adding things to a language. Andrei Taken out of context, no it isn't. "It sounds like a good idea", is a (relati

Re: Octal Literals

2012-07-18 Thread Andrei Alexandrescu
On 7/18/12 10:29 AM, monarch_dodra wrote: I see no reason not to add it This is never a good argument for adding things to a language. Andrei

Re: Octal Literals

2012-07-18 Thread monarch_dodra
Scala as well. I like using octal numbers, and I've always been interested in D's octal literals. I'm glad to see that the traditional syntax of C's octal literals is being replaced by a more readable one. However, I can't help but think that the template solution

Re: Octal Literals

2012-07-18 Thread H. S. Teoh
On Wed, Jul 18, 2012 at 05:06:21PM +0200, Simen Kjaeraas wrote: > On Wed, 18 Jul 2012 16:45:58 +0200, Dave X. wrote: > > >Not that this really matters, but out of curiosity, how does this > >template work? > > It converts the passed number to a string, then works on a digit at a > time. Basicall

Re: Octal Literals

2012-07-18 Thread Simen Kjaeraas
On Wed, 18 Jul 2012 16:45:58 +0200, Dave X. wrote: Not that this really matters, but out of curiosity, how does this template work? It converts the passed number to a string, then works on a digit at a time. Basically: foreach ( digit; number ) { if ( digit >= '0' && digit <= '9' )

Re: Octal Literals

2012-07-18 Thread Caligo
siastically watching D for a while now (I program primarily > in Java and C). I have some functional programming experience in Haskell and > Scala as well. > > I like using octal numbers, and I've always been interested in D's octal > literals. I'm glad to see that the

Re: Octal Literals

2012-07-18 Thread Christophe Travert
"Dave X." , dans le message (digitalmars.D:172680), a écrit : > Not that this really matters, but out of curiosity, how does this > template work? By looking at the sources, if the template argument is a string, the program just compute the octal value as a human would do, that is it makes the

Re: Octal Literals

2012-07-18 Thread Dave X.
Java and C). I have some functional programming experience in Haskell and Scala as well. I wish D had been as far along as it is now back when I was in college! I like using octal numbers, and I've always been interested in D's octal literals. I'm glad to see that the tr

Re: Octal Literals

2012-07-17 Thread Nick Sabalausky
g experience in Haskell and Scala as well. > I wish D had been as far along as it is now back when I was in college! > I like using octal numbers, and I've always been interested in > D's octal literals. I'm glad to see that the traditional syntax > of C's octal li

Octal Literals

2012-07-17 Thread Dave X.
;ve always been interested in D's octal literals. I'm glad to see that the traditional syntax of C's octal literals is being replaced by a more readable one. However, I can't help but think that the template solution ("octal!nnn") is a little too roundabout; is there a

Re: octal literals, was Re: Implicit enum conversions are a stupid PITA

2010-03-26 Thread Don
Rainer Deyke wrote: On 3/25/2010 23:40, Walter Bright wrote: Rainer Deyke wrote: I don't mind octal literals, but '0177' is a horrible syntax. *Every* *single* *time* that I used that syntax in C or C++, I really meant to use a decimal. I'm curious what tempted you to us

Re: octal literals, was Re: Implicit enum conversions are a stupid PITA

2010-03-25 Thread Rainer Deyke
On 3/25/2010 23:40, Walter Bright wrote: > Rainer Deyke wrote: >> I don't mind octal literals, but '0177' is a horrible syntax. *Every* >> *single* *time* that I used that syntax in C or C++, I really meant to >> use a decimal. > > I'm curious w

Re: octal literals, was Re: Implicit enum conversions are a stupid PITA

2010-03-25 Thread Walter Bright
Rainer Deyke wrote: I don't mind octal literals, but '0177' is a horrible syntax. *Every* *single* *time* that I used that syntax in C or C++, I really meant to use a decimal. I'm curious what tempted you to use a leading 0 in the first place.

octal literals, was Re: Implicit enum conversions are a stupid PITA

2010-03-25 Thread Rainer Deyke
support them. I don't mind octal literals, but '0177' is a horrible syntax. *Every* *single* *time* that I used that syntax in C or C++, I really meant to use a decimal. -- Rainer Deyke - rain...@eldwood.com

Re: Octal literals: who uses this?

2009-03-18 Thread Don
e \0 embedded in a string. But in both D and C# you can. So the "\" case isn't really a problem for C. It's far more likely in D that someone would write: "1st\02nd\03rd\04th\0"; and expect it to work. I doubt there is much extant C code which uses octal. Auto

Re: Octal literals: who uses this?

2009-03-17 Thread Walter Bright
BCS wrote: We have plans to release the translator "at some point". That'll be cool!

Re: Octal literals: who uses this?

2009-03-17 Thread BCS
Hello Walter, BCS wrote: Reply to Walter, It is a good point, but I don't see people translating C# to D. But I do see translating C to D (I do it myself!). I am working with a ~11KLOC c# code base and a tool to automatically translate it to D Color me wrong, then! Not to far off, you

Re: Octal literals: who uses this?

2009-03-17 Thread Walter Bright
BCS wrote: Reply to Walter, It is a good point, but I don't see people translating C# to D. But I do see translating C to D (I do it myself!). I am working with a ~11KLOC c# code base and a tool to automatically translate it to D Color me wrong, then!

Re: Octal literals: who uses this?

2009-03-17 Thread BCS
Reply to Walter, It is a good point, but I don't see people translating C# to D. But I do see translating C to D (I do it myself!). I am working with a ~11KLOC c# code base and a tool to automatically translate it to D "I had a problem, I decided to solve it with reg-ex, not I have 200 pro

Re: Octal literals: who uses this?

2009-03-17 Thread Walter Bright
ed translations of octal literals can be done accurately, and you're even supplying the 'htod' converter! htod is not intended for creating implementation source code. It's just for headers. I expect most C translations will be done by hand. Note that C# doesn't have

Re: Octal literals: who uses this?

2009-03-17 Thread BCS
Reply to don, I think the argument for octal is very, very weak. OTOH even if I grant that, I don't see much reason for dropping them.

Re: Octal literals: who uses this?

2009-03-17 Thread Don
Walter Bright wrote: Stewart Gordon wrote: Walter Bright wrote: The octal literals are done the way C does them. The reason they are there are for when translating C code to D code, obscure bugs are not introduced. How would making them illegal not achieve this aim? The only point to

Re: Octal literals: who uses this?

2009-03-14 Thread Christopher Wright
Walter Bright wrote: Christopher Wright wrote: Can we just remove this? The octal literals are done the way C does them. The reason they are there are for when translating C code to D code, obscure bugs are not introduced. Okay, that makes sense. Removing it would be an option; \0 would

Re: Octal literals: who uses this?

2009-03-14 Thread Walter Bright
Stewart Gordon wrote: Walter Bright wrote: The octal literals are done the way C does them. The reason they are there are for when translating C code to D code, obscure bugs are not introduced. How would making them illegal not achieve this aim? The only point to making them illegal would

Re: Octal literals: who uses this?

2009-03-14 Thread BCS
Hello Stewart, Walter Bright wrote: The octal literals are done the way C does them. The reason they are there are for when translating C code to D code, obscure bugs are not introduced. How would making them illegal not achieve this aim? Stewart. Unless you also drop \0 then any octal

Re: Octal literals: who uses this?

2009-03-14 Thread Stewart Gordon
Walter Bright wrote: The octal literals are done the way C does them. The reason they are there are for when translating C code to D code, obscure bugs are not introduced. How would making them illegal not achieve this aim? Stewart.

Re: Octal literals: who uses this?

2009-03-14 Thread Walter Bright
Christopher Wright wrote: Can we just remove this? The octal literals are done the way C does them. The reason they are there are for when translating C code to D code, obscure bugs are not introduced.

Re: Octal literals: who uses this?

2009-03-14 Thread Stewart Gordon
Christopher Wright wrote: Octal literals aren't necessary with hex literals, but they might be convenient. However, making them variable width seems like it opens up the possibility for obscure bugs. I would not recommend that anyone use octal literals, and I don't think they'

Re: Octal literals: who uses this?

2009-03-14 Thread Stewart Gordon
Sean Kelly wrote: All the escaped literals are going away, I believe. I think all that's happening there is the removal of escaped characters not enclosed in quotes. Stewart.

Re: Octal literals: who uses this?

2009-03-14 Thread Jarrett Billingsley
There are three forms of hex literals: > \x: 2 digits > \u: 4 digits > \U: 8 digits > > There is one form of octal literal: > \: 1 to 3 digits > > Why? With hex literals, each option is a fixed width. That is sensible. > > Octal literals aren't necessary with hex

Re: Octal literals: who uses this?

2009-03-14 Thread Sean Kelly
gits \U: 8 digits There is one form of octal literal: \: 1 to 3 digits Why? With hex literals, each option is a fixed width. That is sensible. Octal literals aren't necessary with hex literals, but they might be convenient. However, making them variable width seems like it opens up the

Octal literals: who uses this?

2009-03-14 Thread Christopher Wright
ne form of octal literal: \: 1 to 3 digits Why? With hex literals, each option is a fixed width. That is sensible. Octal literals aren't necessary with hex literals, but they might be convenient. However, making them variable width seems like it opens up the possibility for obscure bu