[erlang-patches] Enhancement of erl_prettypr

Henrik Nord <>
Mon Oct 22 15:33:30 CEST 2012


Patch added to 'master-pu'

Thank you

On 10/16/2012 06:23 PM, Serge Aleynikov wrote:
> Enhancement of erl_prettypr to print binaries in human-readable form.
>
> 	git fetch :saleyn/otp.git erl_prettypr
>
> 	https://github.com/saleyn/otp/compare/erl_prettypr
> 	https://github.com/saleyn/otp/compare/erl_prettypr.patch
>
> Given an abstract syntax form of a binary, such as:
>
> 1> Form = erl_syntax:form_list(element(2, erl_parse:parse_exprs(
>     element(2, erl_scan:string(
>
> "<<84,104,105,115,32,105,115,32,97,32,98,105,110,97,114,121,10>>."))))).
>
> Before applying the patch the output of erl_prettypr:format/1 looks like
> this:
>
> 2> erl_prettypr:format(Form).
> "<<84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 98, 105,\n  110, 97,
> 114, 121, 10>>"
>
> After applying the patch the output looks like this:
>
> 3> erl_prettypr:format(Form).
> "<<\"This is a binary\\n\">>"
>
> The human-readable printing occurs only if erl_prettypr finds out that
> the binary represents a printable list.
>
> Regards,
>
> Serge
> _______________________________________________
> erlang-patches mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-patches

-- 
/Henrik Nord Erlang/OTP



More information about the erlang-patches mailing list