Skip to content

Should flags be represented as enums? #4

Open
@xtian

Description

@xtian

Regarding this TODO:

try writer.line("// TODO: This Enum is marked as [Flags], what do I do with this?");

Is there a big benefit to representing these values as non-exhaustive enums? My impression is that the common case is combining multiple bitmask values together which is awkward with the current setup. For example:

const std = @import("std");
const win32 = @import("win32").everything;

const class = std.mem.zeroInit(win32.WNDCLASSEXA, .{
    .style = @intToEnum(win32.WNDCLASS_STYLES, @enumToInt(win32.CS_HREDRAW) | @enumToInt(win32.CS_VREDRAW) | @enumToInt(win32.CS_OWNDC)),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions