[erlang-questions] Function to print a record with fieldnames ?
Convey Christian J NPRI
ConveyCJ@REDACTED
Tue Mar 4 16:07:21 CET 2008
Thanks Ulf.
Perhaps my inexperience with Erlang is hindering me, but from your blog I don't see how to employ your work. Specifically, the version of the shell I'm using doesn't seem to have the extensions you defined (fa / fl / fr), and even if it did, wouldn't I still need to write a new pretty-printer extension for each tagged record type?
Thanks,
Christian
> -----Original Message-----
> From: Ulf Wiger (TN/EAB) [mailto:ulf.wiger@REDACTED]
> Sent: Tuesday, March 04, 2008 9:38 AM
> To: Convey Christian J NPRI
> Cc: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] Function to print a record
> with fieldnames?
>
> Convey Christian J NPRI skrev:
> > I've got a record definition along the lines of:
> -record(myrec, {foo = undefined, bar=undefined}).
> >
> > To help with debugging, I'd like a function that will print
> out something like the following text:
> > #record{foo = 42, bar = the_answer_to_the_question}
> >
> > Does such a function exist, or must I write my own version
> of the function for each record type? I know I can just use
> io:format("~p~n", [ MyRecord ]), but I'd really like the
> fieldnames to also be printed.
>
> There is such a function - almost (it's not documented, and
> may not do exactly what you want).
>
> I wrote about it a while back in my blog:
>
> http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-sh
> ell-part-1/
>
> BR,
> Ulf W
>
More information about the erlang-questions
mailing list