March 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656



--- Comment #10 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-03-13 07:01:53 PST ---
(In reply to comment #9)
> I agree that the "0o" prefix is not very readable.
> 
> What about using Octal!50 instead (no leading zero. No string)?

Unfortunately that would preclude expressing large numbers in octal.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Require 0o format for octal |Remove octal literals
                   |literals                    |


--- Comment #11 from Don <clugdbug@yahoo.com.au> 2010-03-13 12:19:22 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > I agree that the "0o" prefix is not very readable.
> > 
> > What about using Octal!50 instead (no leading zero. No string)?
> 
> Unfortunately that would preclude expressing large numbers in octal.

I don't think it matters what we do. The point is, octal literals are
*extremely* obscure, and don't need to be in the core language, especially with
such a subtle, bug-prone syntax.
If we agree to remove them from the core language, decision about the syntax
should be treated the same as any other standard library syntax issue. It's not
urgent to decide library naming issues right now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656



--- Comment #12 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-03-13 13:02:23 PST ---
Well put, Don!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


--- Comment #13 from bearophile_hugs@eml.cc 2010-03-25 17:59:51 PDT ---
After a too much long discussion Walter has said:

>I admit it, I just like octal constants. I like the way they look. I don't feel
an urge to kill it with fire. I'd be sad to see them go. I like disco music, too, despite it being definitely out of style.<


So probably octal literals will not go away.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |


--- Comment #14 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-03-25 18:49:55 PDT ---
(In reply to comment #13)
> After a too much long discussion Walter has said:
> 
> >I admit it, I just like octal constants. I like the way they look. I don't feel
> an urge to kill it with fire. I'd be sad to see them go. I like disco music, too, despite it being definitely out of style.<
> 
> 
> So probably octal literals will not go away.

Let's give it a hope. Facts and reason do have to carry some weight. I'll commit octal to Phobos.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656



--- Comment #15 from bearophile_hugs@eml.cc 2010-11-27 14:25:07 PST ---
(In reply to comment #14)
> Let's give it a hope. Facts and reason do have to carry some weight. I'll commit octal to Phobos.

Even MISRA C disallows octal constants. They are useful only in special situations. If Walter can't accept the idea of removing them from D, then an alternative idea is to use a strategy inspired by how GCC deals with trigraphs. This is a C program:


#include "stdio.h"
int main() {
    puts("??-");
    return 0;
}


If I compile it with GCC 4.5 I receive:

...>gcc tritest.c -o tritest
tritest.c: In function 'main':
tritest.c:3:11: warning: trigraph ??- ignored, use -trigraphs to enable

...>tritest
??-


But a compiler switch enables them:

...>gcc -trigraphs tritest.c -o tritest

...>tritest
~

A similar compiler switch like "-octals" may enable octal number syntax in D.

But the idea of numerical constants that change value according to a compiler switch is bad, so I don't want a warning. So a better idea is to turn integral literals that start with one zero into true syntax errors, unless the "-octals" switch is used.

This is useful also because turns standard C syntax (octals) into a syntax error, instead of turning them silently into different values. This follows the D design strategy of behaving (almost everywhere) like C where the C syntax is accepted by the D compiler and producing a syntax error otherwise.

(This is not a tidy solution, but keeping some backwards compatibility with C often asks for not tidy workarounds).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656


Unknown W. Brackets <bugs-d@unknownbrackets.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugs-d@unknownbrackets.org


--- Comment #16 from Unknown W. Brackets <bugs-d@unknownbrackets.org> 2010-11-27 19:56:52 PST ---
(In reply to comment #13)
> After a too much long discussion Walter has said:
> 
> >I admit it, I just like octal constants. I like the way they look. I don't feel
> an urge to kill it with fire. I'd be sad to see them go. I like disco music, too, despite it being definitely out of style.<
> 
> 
> So probably octal literals will not go away.

Not that I like octal literals, but they are still used by some.  I've definitely seen things like 0775 etc. (even though or'd constants should be used.)  Especially in quick scripts that rdmd was created for.

I think changing its syntax, just like D did with ~, makes a lot of sense. Removing it will probably only manage to annoy *someone*.

As for octal!"editor" - why not have imaginary!"1i + 2"?  In fact, why have this 1_000 or 5L nonsense, those should be templates that take strings too.

Saying things are "editor problems" and not caring any further is exactly the way to create a bad language.  People use editors and languages together, not apart.  Creating a feature that's easy for the language developer but terrible for the editor and therefore the end-user is, well, silly at best.

Just IMHO.

-[Unknown]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656



--- Comment #17 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-11-28 08:40:41 PST ---
I wonder what people's experience with octal has been.

http://www.digitalmars.com/d/2.0/phobos/std_conv.html#octal

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656



--- Comment #18 from bearophile_hugs@eml.cc 2010-11-28 08:50:33 PST ---
(In reply to comment #17)
> I wonder what people's experience with octal has been.
> 
> http://www.digitalmars.com/d/2.0/phobos/std_conv.html#octal

I have never had to use octals in D code so far, so I have no experience on that "octal".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2656



--- Comment #19 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2010-11-28 09:53:36 PST ---
(In reply to comment #0)
> D should follow Python's lead in removing the archaic, subtle, and unintuitive format for octal literals. The obvious choices are of the form 0c45 and 0o45. The key argument used for the "0o" format is here:
> 
> http://mail.python.org/pipermail/python-dev/2006-February/060351.html
> 
> and basically argues that since in printf(), "%o" is used for octal, whereas "c" is used for char, "o" is the natural choice.

Haha, this printf argument is laughable. With printf %#x will prepend 0x prefix
to hex number, you can't do this for octal and binary numbers.
I think, 0o775 is ok (you can see it just here). He has a good point that it's
leading zero that signals "something nice is here" and size of o is enough to
figure out, what is this. 0c is just a syntactical hack in attempt to not use
0o.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------