Python pretty-printing [3/6]

Tom Tromey tromey@redhat.com
Mon Apr 6 23:32:00 GMT 2009


>>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes:

Thiago> I think most of these methods could be attributes instead.

Ok.

Thiago> The ones which should stay as methods are those who have
Thiago> side-effects (like causing a symtab to be loaded, or
Thiago> somesuch). Even the methods which create new types only do so
Thiago> if the requested type doesn't exist yet, IIUC. Are there
Thiago> side-effects in, say, Type.pointer or Type.reference?

Only allocation, as far as I can tell.  That seems safe enough.

Thiago> Also, another no-no for an attribute would be if its getter
Thiago> would throw an exception.
Thiago> WDYT?

I'll do it.

This strengthens the argument for changing the Type constructor now,
if we want to.  We might as well make all the changes at once :) What
do you think of a static method named "Type.lookup"?  Daniel?

Thiago> What about making Value.type an attribute?

I remember thinking that we couldn't memoize a value's Type.
But now I'm thinking that I remember this from before type reference
counting; and on the branch it seems like it ought to be safe.

Type is still a bit weird.  We don't have a way to compare Type
objects, which makes them hard to use in dictionaries and whatnot.
One idea would be to compare the underlying struct type, with the
proviso that, in the current gdb, this won't always work correctly for
types with no associated objfile.  This would be an improvement, at
least, and we could lift this restriction later.

Tom



More information about the Gdb-patches mailing list