From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/6] invoke_xmethod & array_view
Date: Mon, 26 Nov 2018 18:28:00 -0000 [thread overview]
Message-ID: <a7aa99edbe1dca56d55034e8c869f86d@polymtl.ca> (raw)
In-Reply-To: <29ddaf6e-1700-4464-fb91-c3dc307b2e7f@redhat.com>
On 2018-11-26 12:54, Pedro Alves wrote:
> On 11/26/2018 05:18 PM, Simon Marchi wrote:
>
>> I acknowledge all these downsides. My opinion (as of today) is that
>> they are reasonable trade-offs. I'm in the camp of "code is written
>> once, read many times". I think that when writing it, it's not
>> difficult to look up what the function you are calling expects (can a
>> pointer be null). But when reading a function, if the little & sign
>> can save a round trip to the called function's doc, I think it's worth
>> it.
>
> In the patch series in question, do you think it helps? IMHO it
> doesn't. Passing a vector by copy would be so strange that I'd
> never think that that is what is going on. Which leaves non
> or non-const references. And then if one has to look up
> the function description to know the function is adding to the vector,
> then that means that one doesn't really have a clue what the function
> is doing, IMO. Once you know, then you just know and the & doesn't
> really help.
It's hard to tell now because as you say, once I know, I know. And I
happen to know now :). Also, this is a case of
did_it_work = get_stuff (stuff);
So in this case, I admit it would be clear either way.
>
> John's series is also passing output vectors by non-const reference:
>
> https://sourceware.org/ml/gdb-patches/2018-11/msg00171.html
>
> and that code looks pretty clear to me as is.
There, it kinda helps that the variable is named "result":
get_syscalls_by_group (gdbarch, group_name, result)
If the result of get_syscalls_by_groups was used for something else than
being returned, it probably wouldn't have been named "result". But even
with that name, I think the & adds a little something that makes it
obvious at the first eyesight, even before parsing the text:
get_syscalls_by_group (gdbarch, group_name, &result)
I'm not saying that it's a major impediment to reading the code, just
one little thing that contribute to readability (IMO). Again, if people
believe this rule is more an annoyance than anything else, we can just
remove it.
Simon
next prev parent reply other threads:[~2018-11-26 18:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20181015151115.6356-1-palves@redhat.com>
2018-10-15 15:11 ` Pedro Alves
2018-10-17 16:21 ` Simon Marchi
2018-11-21 12:47 ` Pedro Alves
2018-11-26 17:18 ` Simon Marchi
2018-11-26 17:54 ` Pedro Alves
2018-11-26 18:28 ` Simon Marchi [this message]
2018-10-15 15:11 ` [PATCH 5/6] valops.c: Some more gdb::array_view Pedro Alves
[not found] ` <4fcedad5-fb6a-11ed-d24f-9e9a3f6339e7@ericsson.com>
2018-11-21 12:48 ` Pedro Alves
2018-10-15 15:11 ` [PATCH 1/6] Use gdb:array_view in call_function_by_hand & friends Pedro Alves
2018-10-17 1:45 ` Simon Marchi
2018-11-21 12:39 ` Pedro Alves
2018-10-15 15:11 ` [PATCH 3/6] Eliminate make_symbol_overload_list-related globals & cleanup Pedro Alves
2018-10-17 17:25 ` Simon Marchi
2018-11-21 12:47 ` Pedro Alves
2018-10-15 15:16 ` [PATCH 4/6] C++ify badness_vector, fix leaks Pedro Alves
[not found] ` <00ee88d8-857d-d85a-db78-b7a05b62ea0b@ericsson.com>
2018-11-21 12:47 ` Pedro Alves
2018-10-15 15:18 ` [PATCH 6/6] valops.c: Overload resolution code: Rename parameters/locals Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7aa99edbe1dca56d55034e8c869f86d@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox