• The integral type 'byte' (was Re: Suggested method for returning a stri

    From Janis Papanagnou@21:1/5 to Keith Thompson on Mon Mar 24 16:59:20 2025
    On 21.03.2025 00:10, Keith Thompson wrote:
    bart <bc@freeuk.com> writes:
    [...]
    Look at this one for example:

    typedef uint8_t byte; // from arduino.h

    I can only one of reason this exists, which is that 'byte' is a far
    nicer denotation.

    I agree in this case. "byte" documents what the type is intended for.

    I disagree on both above expressed opinions in more than one way.

    Byte is a bad term to denote a quantity or an intention. Formerly
    a "Byte" was used to carry characters; its size could be anything
    from 5 to 9 bit. There was a reason why in international standards
    documents there's the 'octet' introduced to unambiguously hint to
    an 8-bit quantity. Neither is it good, as we see in practice, to
    assume a 'byte' (whatever it actually is) to be able to carry a
    character, not even 'char' or 'unsigned char' seem to be able to
    accomplish that given the "wide character" types in the context of
    Unicode (16 bit, 32 bit) characters and (variable-length) UTF-8
    encodings.

    Disclaimer: In the early 1990's we supported an include file like
    the later coming "types.h" where we defined the sized type typedefs
    and (IIRC) also, for "completeness", typedefs like 'byte'. Actually,
    and unlike the "sized" types, 'byte' was never used in practice.[*]

    Janis

    [*] That's why I'm interested to hear about applications where such
    a term proved useful (and better suited than 'octet', 'uint8_t', or
    some sort of 'char').

    [...]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)