Most languages allow block comments, and multiline commands.
For example, a multiline comment in HTML looks like the following:
<!-- Warning, brave programmer: Here be dragons. -->
In Elixir, the closest thing I have found comes from EEx (docs).
EEx smartengine <% #comments %>
seem to be discarded from source, even if they are multiline. However, this is just a workaround.
Does Elixir have a multiline comment feature, or a way to instruct the compiler to discard text from the compiled .beam file?
Comments in Elixir, as is common in languages that can function as scripting languages, use the pound sign. Formally, there's no way to have a multiline comment, but a multiline string will end up being a noop.
Multiline comments are used for large text descriptions of code or to comment out chunks of code while debugging applications. Comments are ignored by the compiler.
Multi-line comments start with /* and ends with */ . Any text between /* and */ will be ignored by Java.
Elixir does not have multiline comments.
However, one very common use case for multiline comments is documenting modules and functions, for which you can use the module attributes @doc
and @moduledoc
together with heredocs.
defmodule MyModule do @moduledoc """ This module is great at X """ @doc """ Frobnicates the given string. """ def frobnicate(s) do end end
Macros could help here to some degree:
defmodule Comment do defmacro comment(_text) do end end defmodule TestComment do import Comment comment """ Module Comment """ def func do comment """ Function Comment """ end end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With