rr(Mod) in the shell

ke.han <>
Wed Sep 7 14:46:53 CEST 2005


Great improvement Claes.  thanks for the code.  I'm patching my erlang 
install immediately!
I suppose the bigger question is how do we know if the "keepers of 
erlang" will accept this submission?  I realize that asking for a formal 
community submission and acceptance process for erlang evolution may 
require more resources than ericsson can provide at the moment.  But 
simple maililst acknowledgement that they are accepting and will get 
submissions like this added in short order would be nice. ;-)
ke han

Claes Wikstom wrote:

>
>
> I've become totally and completely addicted to the
> feature of the shell where rr(Mod) in the shell reads the record
> defs of the Module and displays the records nicely in the shell.
>
> It would be very nice if also records could be nicely printed by
> io:format so we could get nice record printouts in logs. Our
> logs are widely populated by ugly record printouts.
>
> I've patched shell.erl and io_lib_format.erl to accomplish
> this. The format char for records is ~r (ofcource)
>
> I'm not claiming that I understand the code in io_lib
> but if you all think that this is also a nice fetaure, maybe
> someone who understands the io_lib code better than me
> could do it properly.
>
>
> As an example, as session from the shell:
>
> ()3> [P] = mnesia:dirty_read({person, 6003310130}).
> [{person,6003310130,
>          "Claes",
>          "Wikstrom",
>          {addr,[],"Malarhojdsvagen 5a",98765,"Stockholm",[],[],[]},
>          [],
>          [],
>          [],
>          [{53,"247332"}],
>          0,
>          [{4,63279658768},
>           {2,63292552384},
>           {5,63280394364},
>           {3,63283554755},
>           {53,63291634548}],
>          63291634548,
>          ok,
>          262145024,
>          [],
>          [],
>          0}]
>
> ()4> io:format("Person ~r", [P]).
> Person #person{pno = 6003310130,
>         fname = "Claes",
>         lname = "Wikstrom",
>         addr = #addr{careof = [],
>               street = "Malarhojdsvagen 5a",
>               postno = 98765,
>               city = "Stockholm",
>               telno = [],
>               cellno = [],
>               email = []},
>         post_addr = [],
>         extra_company_addrs = [],
>         passwd = [],
>         estore_names = [{53,"247332"}],
>         blacklisted = 0,
>         crdata = [{4,63279658768},
>          {2,63292552384},
>          {5,63280394364},
>          {3,63283554755},
>          {53,63291634548}],
>         crdate = 63291634548,
>         crresult = ok,
>         credlimit_bits = 262145024,
>         letters = [],
>         email = [],
>         flags = 0}ok
>
>
>
>
> The solution (which I believe has been up for disccussion
> earlier here on the list) is pretty expensive, since all
> record defs from all modules are kept in an ets table. I'd
> say it's worth it though, and if the feature isn't used, the
> ets table never gets created.
>
>
> What do you think ??
>
>
> /klacke
>




More information about the erlang-questions mailing list