3 ms·
I think that was the point. If it wasn't clear enough that your ellipses are meant to be showing some thing that was elided, put them in a comment. (In this ca
by yebyen 3y ago
I think that was the point. If it wasn't clear enough that your ellipses are meant to be showing some thing that was elided, put them in a comment.
(In this case, the article used them as valid syntax and added a comment to clarify that this is indeed valid syntax!)
If that isn't what you were doing, and it still isn't clear enough, add some text to the comment about what the "intentionally omitted part" was that you covered by an ellipsis.
- layer8 3y agoI think the root comment was about having a standard for denoting that some code is omitted. In that case, one doesn’t want the code sample to be syntactically valid, in order to unambiguously communicate that it is incomplete. Using comments, however, would typically make the code syntactically valid.
- tialaramex 3y agoSome languages (Rust and Swift for example) have expressions which are placeholders but won't actually work. let x = 5 + todo!("Complicated arithmetic expression"); ... is valid Rust, it typechecks, your syntax highlighter should be fine with it, it'll compile, but if that line ever executes, you panic immediately.
- layer8 3y agoPersonally I think execution time is too late.
- LegibleCrimson 3y agoI disagree. In Rust it's extremely useful to be able to tell if your types are correct and the code will compile with the signatures given, and with multiple placeholders, you can iteratively replace them and test them progressively. I use them heavily during development. Most of my new functions in progress end with an unimplemented! I'm not sure what advantage at all could be gained by preventing it from compiling, other than to save people who copy code without even looking at it some minor inconvenience. Edit: I suppose if you really wanted an existing macro to cause compilation to fail, you could use https://doc.rust-lang.org/std/macro.compile_error.html https://doc.rust-lang.org/std/macro.compile_error.html But I think that's a strange use of it.