This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: [python] more tests and documentation
- From: "Paul Pluzhnikov" <ppluzhnikov at google dot com>
- To: "Tom Tromey" <tromey at redhat dot com>
- Cc: "Project Archer" <archer at sourceware dot org>
- Date: Thu, 23 Oct 2008 14:01:26 -0700
- Subject: Re: [python] more tests and documentation
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1224795689; bh=nftq3wR9Suv8Hef+VQYq7aTB5mQ=;h=DomainKey-Signature:Message-ID:Date:From:To:Subject:Cc: In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-Disposition:References; b=Wsxu0IGzK/xQIdspJdsUMkU9hCNaxzsY0aw27rdxJ3RiDL55FMaXJ7lAveNlv1XGeQT/HQF43dUv9vkt+n/p4A==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;b=VD4VyoHczDp6+4cLDE03Kk6JYzODHOiEbtCUYOFEM1bm+b+wYFaaeT05N6s6yHsq2WXrv4aLGAOgFdZZ+sLJtw==
- References: <m363nk2sve.fsf@fleche.redhat.com> <8ac60eac0810222115w774a8c21oc54d8fc3d9b93268@mail.gmail.com> <m3abcv1g7i.fsf@fleche.redhat.com> <m3d4hrxfhu.fsf@fleche.redhat.com> <m3d4hrvzky.fsf@fleche.redhat.com>
On Thu, Oct 23, 2008 at 1:14 PM, Tom Tromey <tromey@redhat.com> wrote:
> Tom> On second thought, I understand stripping const (and volatile and
> Tom> restrict).
>
> What do you think of this?
Looks good.
You are right about references being automatically dereferenced
and pretty-printed. However consider this:
// --cut-- t.cc
#include <string>
#include <vector>
int main()
{
std::vector<std::string> vs;
vs.push_back("Hello");
vs.push_back("World");
return vs[0].length(); // break here
}
// --cut-- end
Without stripping references (current code), this prints:
(gdb) p vs
$1 = std::vector of length 2, capacity 2
[0] = 0x603028 "Hello"
[1] = 0x603078 "World"
(gdb) p vs[0]
$2 = (std::basic_string<char,std::char_traits<char>,std::allocator<char>
> &) @0x603090: 0x603028 "Hello"
But if I do strip reference type, it prints:
(gdb) p vs
$1 = std::vector of length 2, capacity 2
[0] = 0x603028 "Hello"
[1] = 0x603078 "World"
(gdb) p vs[0]
$2 = 0x603028 "Hello"
Notice that (from the end user perspective) 'print vs' and 'print
vs[0]' are semantically very close, so it's surprizing that one
prints more "junk" than the other.
Also, in real usage we often have
vector<some-complicated-type-with-20-template-parameters>, so
now 'print vs[0]' results in 20 lines of "junk" followed by the
info that user actually wants.
--
Paul Pluzhnikov