pretty-printing through the shell

Ulf Wiger (AL/EAB) <>
Tue May 24 14:14:52 CEST 2005


I thought I'd try a small hack to the shell:

> diff shell.erl $OTP_ROOT/lib/stdlib-1.13.6/src/shell.erl
23d22
< -export([format/1]).
44,47d42
< format(Term) ->
<     io_lib_pretty:print(Term, ?LINEMAX, record_print_fun(?RECORDS)).
< 
< 
169c164
<     RT = ets:new(?RECORDS, [public,named_table,ordered_set]),
---
>     RT = ets:new(?RECORDS, [public,ordered_set]),


Now, given the following test function:

-include("dialyzer.hrl").
...
print() ->
    S = shell:format(#options{}),
    io:format("Output: ~s~n", [S]).


1> test:print().
Output: {options,[],[],cerl_typean,[],byte_code,[],undefined,[],none,false,none,batch}
ok
2> rr("dialyzer.hrl").
[analysis,options]
3> test:print().      
Output: #options{files = [],
         files_rec = [],
         core_transform = cerl_typean,
         defines = [],
         from = byte_code,
         include_dirs = [],
         legal_warnings = undefined,
         output_file = [],
         init_plt = none,
         update_plt = false,
         new_plt = none,
         cl_mode = batch}
ok

Wouldn't this be rather handy for debugging printouts? (not that we ever use debugging printouts anymore...;)

/Uffe



More information about the erlang-questions mailing list