rr(Mod) in the shell

orbitz <>
Wed Sep 7 16:49:55 CEST 2005


Does it still work if you have the same record name but different  
definitions for different modules?  For instance, an ugly habit I have  
is to hold processor state I create a record local to that module named  
'self'.  So every module has it's own self record.  I don't know how  
the record system works but that wouldn't be a problem would it?

On Sep 7, 2005, at 9:55 AM, Ulf Wiger (AL/EAB) wrote:

>
> Agreed. I think it's a good idea too  ;-)
> (http://www.erlang.org/ml-archive/erlang-questions/200505/ 
> msg00201.html)
>
> One problem I ran into was printing from a remote shell.
> I haven't checked whether that will be a problem with
> your code as well, and it wasn't actually clear to me
> why it was happening at all. Something about the translation
> of pids, I think, that causes it not to find the ets table
> (because it gets confused about whether it is local or remote)
>
> Perhaps that's something one can live with...
>
> /Uffe
>
>> -----Original Message-----
>> From: 
>> [mailto:]On Behalf Of Claes Wikstom
>> Sent: den 7 september 2005 13:10
>> To: 
>> Subject: rr(Mod) in the shell
>>
>>
>>
>>
>> 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