Number literals (Was: Re: Case Range Statement ..)
Don
nospam at nospam.com
Wed Jul 8 00:37:51 PDT 2009
Walter Bright wrote:
> Jarrett Billingsley wrote:
>> On Tue, Jul 7, 2009 at 11:20 PM, Walter
>>> Translating C code to D.
>>
>> I don't see this as a reasonable justification. Octal isn't used that
>> much in C either, and D is already so far from C that you need an
>> automated tool to do it, so you might as well just have the tool
>> translate them. The compiler could even disallow leading zeroes,
>> giving you an error on any integer literals that weren't automatically
>> translated.
>
> I've translated code, and a tool isn't really necessary. But translating
> octal constants to hex like 077733 is very error prone. And yes, I ran
> into a bunch of them just recently in the OSX system header files. So
> they exist. I don't see a good reason to make things difficult to
> translate.
Make a leading 0 illegal, and either:
(1) change the octal syntax into 0c77733,
or(better) (2) provide an octal conversion function in the standard library.
Because of CTFE, so we can actually do (2) very nicely. I don't see any
need for it to be a language feature when a library can do a better job.
More information about the Digitalmars-d
mailing list