Skip to content
Cameron Purdy edited this page Apr 8, 2020 · 2 revisions

The TODO expression is used to indicate that some feature or functionality is not complete. In its simplest form, it is used as a means to avoid writing the boilerplate code necessary to get something to compile. TODO is an expression, but ExpressionStatement allows it to be used as a Statement:

Result doComplicatedSimulation()
    {
    TODO
    }

The alternative would be for the developer to first write out a comment to act as a reminder, and then throw an exception to indicate that the feature is not available:

Result doComplicatedSimulation()
    {
    // TODO implement simulation using monte carlo
    throw new UnsupportedOperation();
    }

And that is exactly what this does, except that the comment is reported as part of the exception:

Result doComplicatedSimulation()
    {
    TODO implement simulation using monte carlo
    }

Alternatively, the expression can be used as if the TODO were a function call:

return val < 0 ? TODO("handle negatives") : process(val);

The TODO allows a developer to violate the rules of completion; once a TODO is encountered on a given code path, that code path may then contain unreachable code without generating a compiler error:

protected Node advance(Node node)
    {
    this.node = node;
    TODO this is broken; we need to pass an existence indicator
    if (recalibrate(node))
        {
        return node;
        }
    return this;
    }

As an expression, TODO is expected to have a type, so during validation, it will validate against any requested type.

TODO does not complete.

    ToDoExpression:
        TODO TodoFinishopt

    ToDoFinish:
        InputCharacterexcept '(' InputCharacters LineTerminator
        NoWhitespace ( Expression )