Hacker News new | ask | show | jobs
by aravindet 1877 days ago
The todo keyword https://gleam.run/book/tour/todo.html is brilliant. Are there any other languages that have this?
8 comments

Elm has `Debug.todo`. If you were to use this, it allows your app to compile in development but the app would crash should it hit this code.

Elm's compiler will prevent you from creating a production application with a `Debug.todo` still in place.

Probably based a little on this: https://doc.rust-lang.org/std/macro.todo.html
You can get a similar effect in Elixir with # TODO comments if you're using Credo.

It's just a code comment, but by default Credo will exit non-zero if it sees one so if Credo is part of your CI pipeline it will fail it by default.

I'm one of those annoying people who puts # TODO comments all over my code though, so I set Credo so that TODO's wouldn't fail the build.

AFAIK there's no reason support, but you can make a whole in Scala using ??? as the right-hand side.
it's not the same, but it's almost idiomatic to leave unfinished python code with "..." (the ellipsis object)

    def foo(bar, baz):
        ...
is a valid (empty) python function
Yeah, but this is best used for abstract methods or type stubs. I think in 'real code' you would want to raise NotImplementedError, or even (if you use mypy) potentially return a NoReturn

ie: from typing import Any, NoReturn

    def foo(bar: Any, baz: Any) -> NoReturn:
        raise NotImplementedError
Oh, interesting. I’ve always used “pass” for this.
Perl has ellipsis which will die on use.
kotlin has TODO("reason")
Scala has `???`, which does a similar thing.