[erlang-questions] Finding inconsistencies in record definitions and pretty printing records

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Wed Oct 15 08:56:58 CEST 2008


Joe Armstrong skrev:
> Thanks - so now I can hack this to fetch RecDefFun at run-time :-)
> 
> /Joe

The shell already fetches the record definitions at run-time,
so no need to hack io_lib_pretty...

...although I did, of course, but that was just to support
custom formatting of complex data structures, such as:

3> dict:from_list([{N,a} || N <- lists:seq(1,5)]).
<|dict:[{3,a},{2,a},{5,a},{1,a},{4,a}]|>

BR,
Ulf W

> 
> 
> On Tue, Oct 14, 2008 at 5:51 PM, Ulf Wiger (TN/EAB)
> <ulf.wiger@REDACTED> wrote:
>> Joe Armstrong skrev:
>>> For a production version some improvements are necessary:
>>>
>>>     - ...
>>>     - improve pretty printer
>> Therer is already a good pretty printer of records in OTP:
>> io_lib_pretty:print(Term, Column, LineLength, Depth, RecDefFun)
>>
>> where Column is typically 1, LineLength = 30 in the shell,
>> and RecDefFun = fun(Tag, N_fields) -> [Field_name] | no
>>
>> See shell.erl for how it's used.
>>
>> I played around with it here:
>> http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-shell-part-1/
>>
>> BR,
>> Ulf W
>>



More information about the erlang-questions mailing list