Search code examples
delphipascallazarus

What is the difference between "Byte" and "byte"?


I can define a byte using:

a:  byte; 

and also can define with following:

a:  Byte; 

The compiler will pass for above two situation, but what is the difference of the byte and Byte?


Solution

  • There is absolutely no difference. All versions of Pascal (including Delphi and Free Pascal) are case-insensitive (with very few exceptions - see below), so you can use any of the below - they're all exactly the same thing.

    a: byte;
    a: Byte;
    a: bYTe;
    A: bytE;
    A: BYTe;
    

    There are very few places Delphi is case-sensitive, and these specific exceptions are described in the documentation for H2365 Override method %s.%s should match case of ancestor %s.%s:

    Here are some situations in which Delphi is case-sensitive:

    Unit References and the Uses Clause

    In unit declarations and uses clauses, unit names must match the file names in case. In other contexts (such as qualified identifiers), unit names are case insensitive. To avoid problems with unit references, refer to the unit source file explicitly:

    uses MyUnit in "myunit.pas";
    

    Registering components

    When you write your own components and you want to register them, the register function that you declare must be written like this:

    procedure Register;  <<-- Leading capital required.  
    

    The name of the Register procedure is case-sensitive for design-time packages. If you declare a register procedure (lower-case), and even if hint H2365 is not emitted, you do not get the expected result; your component does not get registered. For more information, see Using the RegisterComponents Procedure.

    Importing external functions

    When importing external functions, the exact case used in the DLL must be preserved.