Skip to content

style_example.zig suggests aliases of primitive types should be snake_case, but standard library differs #25859

@taylordotfish

Description

@taylordotfish

style_example.zig in the language reference suggests that aliases of primitive types should be snake_case:

const primitive_type_alias = f32;
const string_alias = []u8;

However, the standard library does not seem to adhere to this convention:

bit_set.zig
681:    pub const MaskInt = usize;
1085:    pub const MaskInt = usize;

fmt.zig
221:pub const ArgSetType = u32;

hash_map.zig
554:        pub const Hash = u64;

math/big.zig
5:pub const Limb = usize;

os/uefi/tables.zig
274:pub const PhysicalAddress = u64;

zig/Ast.zig
27:pub const ByteOffset = u32;
36:pub const TokenIndex = u32;

zig/ErrorBundle.zig
22:pub const String = u32;
24:pub const OptionalString = u32;

zig/llvm/Builder.zig
4878:        pub const ExtraIndex = u32;
7272:        const ExtraIndex = u32;
8111:        const ExtraIndex = u32;

There are cases of snake_case primitive aliases, but they almost all appear to be C type equivalents, like uintmax_t, time_t, and socklen_t, which I wouldn't expect to adhere to the naming conventions (much like the DWORD alias in windows.zig). So it seems like, in practice, the convention for type aliases is to use TitleCase always.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.docs

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions