[comp.sys.amiga.advocacy] A change to the C++ standard

rcs91900@zach.fit.edu ( Charles Stockman /ADVISOR-Clutterham) (04/06/91)

I am writing a C++ compiler and have one quick question

In C/C++ Octal is defined as 

      012 (octal) --> 10 (decimal)

Instead of starting octals off with a 0 I am planning to start them of with
0o 
   
      0o12 (octal) --> 10 (decimal)

The reason is that I want to make it easier to build the scanner.  By using
0o all I would have to do is check for 0o and surely know if it was an
octal or not.  In the Ansi standard either an octal or a floating digit 
may start with a 0 so it would take longer to decide if it was an octal or
floating point and the code would not be as clean.

        045 --> octal
        0.3 --> floating point

Well --> What do you think, should I change it or keep it the same ?

cs326ag@ux1.cso.uiuc.edu (Loren J. Rittle) (04/06/91)

In article <2264@winnie.fit.edu> rcs91900@zach.fit.edu ( Charles Stockman /ADVISOR-Clutterham) writes:
>I am writing a C++ compiler and have one quick question
>
>In C/C++ Octal is defined as 
>
>      012 (octal) --> 10 (decimal)
>
>Instead of starting octals off with a 0 I am planning to start them of with
>0o 
>   
>      0o12 (octal) --> 10 (decimal)
>
>The reason is that I want to make it easier to build the scanner.  By using
>0o all I would have to do is check for 0o and surely know if it was an
>octal or not.  In the Ansi standard either an octal or a floating digit 
>may start with a 0 so it would take longer to decide if it was an octal or
>floating point and the code would not be as clean.

Unless you are designing an ad hoc scanner (i.e. you aren't using
Lex and Yacc/Bison), the above is not true.  If you *are* designing
an ad hoc scanner, then I say you're crazy :-).

Even if you are designing an ad hac scanner (you're still crazy),
if it starts with 0[^.] then you know it is octal.  Scanning for
0[^.] should be of the same complexity as scanning for 0o.

In any event, I would not deviate from the standard...  Put it is
your project and you can take any short cuts you want...

>        045 --> octal
>        0.3 --> floating point
>
>Well --> What do you think, should I change it or keep it the same ?

In sum, keep it the same.

Loren J. Rittle
-- 
``NewTek stated that the Toaster  *would*  *not*  be made to directly support
  the Mac, at this point Sculley stormed out of the booth...'' --- A scene at
  the recent MacExpo.  Gee, you wouldn't think that an Apple Exec would be so
  worried about one little Amiga device... Loren J. Rittle  l-rittle@uiuc.edu

ckp@grebyn.com (Checkpoint Technologies) (04/06/91)

In article <2264@winnie.fit.edu> rcs91900@zach.fit.edu ( Charles Stockman /ADVISOR-Clutterham) writes:
>I am writing a C++ compiler and have one quick question
>Instead of starting octals off with a 0 I am planning to start them of with
>0o 
>      0o12 (octal) --> 10 (decimal)

This is not a good idea.  This makes your compiler unable to compile a
great deal of existing code, so you shouldn't really call it C++.
Of course, if you want to invent a new language, that's up to you!  Then
you could make all the arbitrary syntax decisions you want to.
-- 
First comes the logo: C H E C K P O I N T  T E C H N O L O G I E S      / /  
                                                ckp@grebyn.com      \\ / /    
Then, the disclaimer:  All expressed opinions are, indeed, opinions. \  / o
Now for the witty part:    I'm pink, therefore, I'm spam!             \/

rkitts@netcom.COM (Rick Kitts) (04/07/91)

In article <2264@winnie.fit.edu> rcs91900@zach.fit.edu ( Charles Stockman /ADVISOR-Clutterham) writes:
>I am writing a C++ compiler and have one quick question
>
>In C/C++ Octal is defined as 
>
>      012 (octal) --> 10 (decimal)
>
>Instead of starting octals off with a 0 I am planning to start them of with
>0o 
>   
>      0o12 (octal) --> 10 (decimal)
>
>The reason is that I want to make it easier to build the scanner.
> [...]

What type of scanner do you plan to build? I assume that you will be using
a greedy algorithm, meaning that it will be a simple thing to check first
that the constant starts with a 0 and that it does or does not contain
a decimal point. I think that you might wish to re-examine your scanner 
design if this is in fact a real problem.

>Well --> What do you think, should I change it or keep it the same ?

Not using octal constants myself I really don't care very much. But I must
tell you that a compiler would have to generate outrageously efficient code
for me to purchase it if it did not conform to the standard.