I'm experimenting with syntax in examples. I don't really like Rust's `assert(inc(1) == 2)` syntax, I find it a little distracting.
I'm trying `inc(1) //-> 2`. The comment is rendered differently, and there's nothing before the sample code. What do you think?
Wilfred Hughes
@wilfredh the advantage of the assert family is that docs are tested by the compiler so they never diverge from reality.
If it's just a comment then you lose that feature.
Chris Denton@chrisdenton@hachyderm.io
@chrisdenton @wilfredh Elixir has "doctests" that are automatically tested, like Rust's, but follow a more example style:
https://hexdocs.pm/elixir/docs-tests-and-with.html#doctests.
J3RN :emacs: :haskell:@j3rn@fosstodon.org
it took me a while to understand what the assert syntax was saying, i always write the expected output in a comment
or a print statement with a comment
@chrisdenton Yep, it’ll need extra tooling support, but I think it might be worthwhile for the friendlier syntax.
Wilfred Hughes
@wilfredh It doesn't feel sufficiently better to be worth an unusual syntax.
I also think it is less nice for inequality asserts:
assert var > 5
vs
var > 5 //-> True
Karl Bartel@karlb@fosstodon.org