Is the world coming to an end?

Steven Schveighoffer schveiguy at yahoo.com
Mon Apr 4 08:19:41 PDT 2011


On Mon, 04 Apr 2011 11:16:32 -0400, Iain Buclaw <ibuclaw at ubuntu.com> wrote:

> == Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
>> On Sun, 03 Apr 2011 07:48:24 -0400, spir <denis.spir at gmail.com> wrote:
>> > On 04/03/2011 02:52 AM, bearophile wrote:
>> >> Michel Fortin:
>> >>
>> >>> The new syntax is certainly usable, it's just inelegant and hackish.
>> >>> Its your language, it's your choice, and I'll admit it won't affect  
>> me
>> >>> much.
>> >>
>> >> My suggestions for Walter are:
>> >> - To turn 01 .. 07 too into errors;
>> >> - to deprecate the octal! Phobos template.
>> >> - To introduce the 0o leading that works from 0o0 to the uint.max;
>> >> - To change the new error message, so it suggests to use 0o.
>> >> - To ask opinions to the community here next time before changing
>> >> things in D2/D3 :-)
>> >
>> > I'm very surprised of this move -- aside the concrete details. What I
>> > point out here is how far sentiments about what is "obvious" or
>> > "correct" can be, for a given issue, that most of us considered wrong
>> > for the same reason.
>> >
>> > When I introduced the topic of octal notation 0nnn beeing bad, I was
>> > 100% sure that (if a move was ever made) either octals would be thrown
>> > out of D all together for beeing nearly useless, or the syntax would  
>> be
>> > fixed -- the "obvious" "correct" solution if octals remain. While I  
>> new
>> > about octal!, this was so hackish and obviously wrong *for me*, that I
>> > did not even imagine one second it could become the "official"  
>> solution.
>> > I'm certainly not the only one.
>> > Questions of detail, sure, but we all know what the details hide ;-)
>> Octal literals *are* out of the language, it's no longer supported.
>> Because of historical reasons, the syntax is disallowed (otherwise,  
>> ported
>> code from C that used octal notation would be horrifically broken).
>> The octal template is a separate addition to allow octal in the very few
>> places it is needed.
>> IIRC, you never complained that octal notation is horrible because you
>> wanted to *use* octal, it's because you *accidentally* used it.  This
>> change fixes your problem, you can't accidentally use the octal literal
>> notation.  So why the complaints?
>> -Steve
>
> Both ways compile down to the same instruction.
>
> auto a = 0777;          // movl   $0x1ff,-0x4(%ebp)
> auto b = octal!777;     // movl   $0x1ff,-0x8(%ebp)
>
>
> The only real difference is the latter method:
> - Instantiates and emits a (possibly unwanted) template, so those who  
> still
> believe in bloat are kicking themselves.

That is something that D suffers from in general.  All CFTE-only templates  
shouild be optimized out (e.g. isInputRange, etc.).  It seems every  
release of phobos adds more templates, and grows in size both the library  
and the traditional "hello world" program.

-Steve


More information about the Digitalmars-d mailing list