Can we have public quoted_to_algebra?

34 views
Skip to first unread message

Serge Smetana

unread,
Apr 11, 2018, 8:08:49 AM4/11/18
to elixir-lang-core
Hello,

We have Code.Formatter.to_algebra(string, opts) used by Code.format_string!
Can we also have Code.Formatter.quoted_to_algebra(quoted, opts)?

I am looking the way to format quoted with heredoc metadata as heredoc.
Currently, there is no way to do it because we cannot format quoted
and Macro.to_string() does not output heredocs.

{:__block__, [format: :bin_heredoc, line: 1], ["foo\nbar\n"]}
|> Macro.to_string()
# => "\"foo\\nbar\\n\""

You can do it only with block_to_algebra which is private in Code.Formatter.
If we could have public quoted_to_algebra this could be possible.

Thanks,
Serge

José Valim

unread,
Apr 11, 2018, 10:31:36 AM4/11/18
to elixir-l...@googlegroups.com
All of the Code.Formatter is private API. There is no guarantee we will keep API compatibility in future versions.

We have no plans to expose it because the formatter works on a specially annotated and private version of the AST.



José Valim
Founder and 
Director of R&D

--
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 elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1c137b43-3c31-4560-9584-507aaab22a4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages