Skip to content

parseNodeQ makes code unclear #528

@ntrel

Description

@ntrel
    template parseNodeQ(string VarName, string NodeName)
    {
        enum parseNodeQ = `{ if ((` ~ VarName ~ ` = parse` ~ NodeName ~ `()) is null) return null; }`;
    }
// many lines...
    mixin(parseNodeQ!(`node.type`, `Type`));

This hides the important code of node.type = parseType. Clearer mixin usage would be something like:

    mixin(checkNull!`node.type = parseType()`);

And it's only 2 characters longer. Now the important code is at least visible and will show up when grepping for parseType. (Or for more clarity the mixin could be named returnIfNull).

I'm happy to make a PR if this is acceptable.

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