| Deutsch English Français Italiano |
|
<86zffq2wnn.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch <tr.17687@z991.linuxsc.com> Newsgroups: comp.lang.c Subject: Re: Regarding assignment to struct Date: Mon, 05 May 2025 21:25:16 -0700 Organization: A noiseless patient Spider Lines: 24 Message-ID: <86zffq2wnn.fsf@linuxsc.com> References: <vv338b$16oam$1@dont-email.me> <3fd0dce206153c0d2dc7cf26291165c3381e9bc2@i2pn2.org> <20250504110117.00005aaa@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 06 May 2025 06:25:18 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f84420402be78ce51ba0e8f0077f27e2"; logging-data="2229925"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VtsA4rrQuLik89JsgiMGy0WLnb71ghmk=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:9Sm8L3ml5TJk4BpWGUaDZGLkGG0= sha1:zYNRA57iXJjyOuwu3PTsuXRz7Qo= Bytes: 2192 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).