ADA and base prefix for numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[CC trimmed]

Hi Branden,

On 2/18/23 20:03, G. Branden Robinson wrote:
> Mainly because Alex is reading, I will point out that Ada did this, and
> several other aspects of numeric literals, right--40 years ago.
> 
>>> Numeric literals are all introduced by an initial digit. A
>>> requirement that has long been recognized when printing numeric
>>> tables is for a character to break up long sequences of digits: in
>>> Ada, the underline character serves this purpose. In contrast to
>>> identifiers, underlines in numeric literals do not alter the meaning,
>>> so that 12_000 naturally has the same value as 12000.
>>>
>>> A simple sequence of digits is an integer literal written in decimal
>>> notation. For other bases from 2 up to 16, the base is given first
>>> and is followed by a sequence of digits enclosed by sharp characters
>>> (#) or by colons (:), the colon being used as replacement character
>>> for the sharp, but only when the sharp is not available. The enclosed
>>> digits may include the letters A to F for bases greater than ten.
>>> Thus, the conventional ways of expressing bit patterns in binary,
>>> octal, or hexadecimal are provided.
>>>
>>> Real literals must contain a period, which represents the radix
>>> point. They may be expressed in decimal notation or with other bases.
>>> Finally, both integer and real literals may include the letter E
>>> followed by an exponent.

I like Ada's base selection :-)
Even if one will rarely use anything other than 2, 8, 10, and 16,
it's interesting to be able to.  C's is not completely broken, and
I'd like it to follow Python and add 0o for octal (and deprecate 0
as a prefix), which would fix the most aberrant thing I hate from
C's numeric literals.
  
> 
> http://archive.adaic.com/standards/83rat/html/ratl-02-01.html#2.1

[I still didn't finish reading it, but am doing :)]

> 
> But C programmers have long indulged in the sport of ignoring every
> lesson any other programming language had to teach, whether through
> careful design or blundering mistake.[1]  C'est la vie.

[...]

> 
> Regards,
> Branden
> 
> [1] Thompson discarded type checking and "//" comments from BCPL; the
>     latter came back relatively painlessly (though only in C99, which
>     Ritchie refused to endorse).  The former has been resurrected in
>     fitful stages, and only where the suffering imposed by careless
>     typing can be discerned as imposing engineering costs in defect
>     resolution greater than in initial implementation by a factor of
>     1,000 or more.
> 
>     https://www.bell-labs.com/usr/dmr/www/chist.html

I have some consistency fixes pending for the Linux man-pages:

-  Use // where the comment is a single line _and_ affects only
   the code in the same line (not below, not above).
-  Use /**/ elsewhere.

Cheers,

Alex

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux