What about "hoisting" the comments into the metadata of the surrounding
block for the primitive AST nodes?
This means that we need to be able to specify *where* in a `:__block__` a
comment ought to occur, which shouldn't be a problem: The only cases where
this information will be out of date is when macro rewriting alters the
AST, which is a situation that would probably remove the comments anyway.
(so e.g. a formatter would need to move comments with the code just as is
the case currently, but optimization tools would not care about comments
anyway).
This 'where' might take the format of a keyword-list, with
half-line-numbers as keys and strings (containing the actual comments) as
values. 'half-line-numbers ' go from 0 up to and including
`2*n_lines_in_block`. Even numbers are comments occuring before (e.g. on
the line above) `div(half-line-number, 2)`. Odd numbers are comments
occuring after (at the end of the same line as) `div(half-line-number/2)`.
So
quote do
# one is the lonliest number
1
2 # two is the smallest prime
3
# I am at the end
end
would compile to
{:__block__, [comments: [0 => "one is the lonliest number", 3 =>
"two is the smallest prime", 6 => "I am at the end"]], [1,2,3]}
~Marten / Qqwy
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/dd4ca588-c646-4eaf-bedc-2e083bc7ad7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.