@wilfredh if it's part of the compiler/interpreter then first class. If it's an external tool (even if official), something you expect people to extend, or some kind of plugin then comments.
badtuple@badtuple@mastodon.social
@badtuple @wilfredh I agree, and yet why not a half measure: first class ephemeral meta data annotations that are only present in the AST but later discarded (not part of the production). This way any tool that uses the AST can inspect those annotations; however they cost nothing and don't alter the binary and they won't even show up for reflection.
External tools can always rely on comments (always there). But those with better integration get a boost?
Pierre@maccatalan@techhub.social
Rust's attribute system is awesome and it will be even more awesome once `register_*_tool` is stabilized.
@wilfredh one problem with making them comments is that they are not formattable and this poisons the lines around the suppressed-lint from being formatted. The rust technique ensures formatting continues to work (and even that long lint suppressions could be formatted for line wrapping)
Jon Janzen@jonjanzen@mastodon.social
@wilfredh Syntax. Make comments first-class too, while you're at it.
l'empathie mécanique@dpwiz@qoto.org
@jonjanzen Wow, this is by far the strongest argument for first class syntax. Thanks, I'd not considered this angle.
Wilfred Hughes
@dpwiz First class comments are pretty darn rare, aren't they? I know some lisps and Python use a plain string for their doc comment, but I've not seen proper first class comments in any language I can think of.
Maybe Smalltalk comes close?
Wilfred Hughes
@wilfredh Unfortunately, yes. First teachers make their students shoot themselves in the foot by treating comments as whitespace. Then everyone has to do extra work with crazy grammars to claw the structure back and/or make a formatter.
l'empathie mécanique@dpwiz@qoto.org
@maccatalan @badtuple That's a really interesting approach, but I worry it'd lead to subtle bugs.
I also think that a first-class metadata annotation would be a good fit for things like inline-this-function instructions to the compiler, so I suspect you'd end up with them affecting the binary.
Wilfred Hughes
@wilfredh Maybe Erlang?
-doc """
some markdown inside
""".
I don't know about its rep, but looks pretty first-class.
Python also yes, with the __doc__ attribute you can access AND generate at runtime.
l'empathie mécanique@dpwiz@qoto.org
@wilfredh @maccatalan My impulse comes from the idea that comments belong to your users, not you.
The contract of comments is that the compiler discards them. That's why they're abused by tooling all the time. Users can stuff metadata or docs or curse words in there and your language doesn't care.
Purely from a user's perspective: If you want something in the language, put it in the language. If you're giving me an area and telling me it's mine then stay away from it.
badtuple@badtuple@mastodon.social