Skip to content

Enforce initialization in more contexts / everywhere / up to debate #49

@Araq

Description

@Araq

Nim should enforce explicit initialization in all code paths rather than relying on default(T). This helps the optimizer, makes code easier to read/follow and can prevent minor bugs in the program logic. It also means that nil can only creep into your program when you write it explicitly, a good compromise given that the not nil annotation doesn't work well with generic containers like Table.

This will also fit the new move semantics perfectly well as we can use the same algorithm that detects "variable used before initialization" for "variable used after move".

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