This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [python] refactor pretty-printing, again

On Tue, Nov 11, 2008 at 5:52 PM, Tom Tromey <> wrote:

> This patch refactors pretty-printing again.
> Now, formatting is done in C rather than in Python.  This made it
> simpler to handle the recursion case.  Recursing is needed, rather
> than string-izing, to make indentation work out nicely in the 'pretty'
> case.

This would also make "mixed" printing easier, wouldn't it?

> I got rid of the value_print hook.  Perhaps this was overly eager of
> me -- now we print references more verbosely.  Paul, let me know what
> you think.  This is easily restored if needed.

I like the indentation and layout consistency :)
But I don't like references :(

In "normal" usage, when "vs" is a std::vector<std::string>, you get:

(gdb) p vs
$1 = std::vector of length 2, capacity 2 = {[0] = 0x404028 "Hello",
[1] = 0x404078 "World"}

(gdb) p vs[0]
$2 = (std::basic_string<char, std::char_traits<char>,
std::allocator<char> > &) 0x404028 "Hello"

Not so pretty ... Though definitely better than 'raw':

(gdb) p/r vs[0]
$3 = (std::basic_string<char, std::char_traits<char>,
std::allocator<char> > &) @0x404090: {static npos =
  _M_dataplus = {<std::allocator<char>> =
{<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data
fields>}, _M_p = 0x404028 "Hello"}}

I wonder if printing the reference (and the address of string)
should be controlled by a separate 'print reftype on/off',
'print arrayaddr on/off', or some such?

Paul Pluzhnikov

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]