Sujet : Re: Regarding assignment to struct
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 06. May 2025, 05:25:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86zffq2wnn.fsf@linuxsc.com>
References : 1 2 3
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Michael S <
already5chosen@yahoo.com> writes:
On Sat, 3 May 2025 21:42:37 -0400
Richard Damon <richard@damon-family.org> wrote:
>
Bigger than that, and you likely want to pass the object by address,
not by value, passing just a pointer to it.
>
That sort of thinking is an example of Knutian premature optimization.
I don't agree with this assessment. First, the given suggestion is
a rule of thumb. By their nature rules of thumb offer heuristics
that give guidelines likely to yield good results, but not
guaranteed to do so. Second, a decision about whether to pass a
struct object or a pointer to said object is often one that is a
fair amount of work to undo, and so tends to be made early during
the time period of program development. As such, it is useful to
follow a guideline likely to give good results, even if not always
optimal, because on average it will mean less work done overall.
I second Richard Damon's recommendation, with the understanding that
it is only a guideline, not an absolute, and as always subject to
later revision should that turn out to be called for (no pun
intended).