12 ms·
The todo keyword https://gleam.run/book/tour/todo.html https://gleam.run/book/tour/todo.html is brilliant. Are there any other languages that have this?
by aravindet 5y ago
The todo keyword https://gleam.run/book/tour/todo.html https://gleam.run/book/tour/todo.html is brilliant. Are there any other languages that have this?
- ModernMech 5y agoProbably based a little on this: https://doc.rust-lang.org/std/macro.todo.html https://doc.rust-lang.org/std/macro.todo.html
- _ZeD_ 5y agoit'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
- senkora 5y agoOh, interesting. I’ve always used “pass” for this.
- staticassertion 5y agoYeah, 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
- toast0 5y agoPerl has ellipsis which will die on use.
- roebk 5y agoElm 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.
- ink404 5y agokotlin has TODO("reason")
- blandflakes 5y agoAFAIK there's no reason support, but you can make a whole in Scala using ??? as the right-hand side.
- the_duke 5y agoRust has the `todo!()` macro: https://doc.rust-lang.org/std/macro.todo.html https://doc.rust-lang.org/std/macro.todo.html Haskell has "typed holes": https://downloads.haskell.org/~ghc/7.10.1/docs/html/users_guide/typed-holes.html https://downloads.haskell.org/~ghc/7.10.1/docs/html/users_gu...
- brightball 5y agoYou 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.
- lalaithion 5y agoScala has `???`, which does a similar thing.