Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: structs passed by copy Date: Sat, 11 Feb 2023 15:08:04 -0800 Organization: None to speak of Lines: 26 Message-ID: <87o7pzdcmj.fsf@nosuchdomain.example.com> References: <76ec6d87-0f5d-4671-b4c8-7023e3da787an@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="eba76493e1aa7d75b90fffca68aee853"; logging-data="1626684"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dCw8GC0S8wOJFrg/l4w+y" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:iCYGjxPB0vvnZlafzKtIiY9wPHA= sha1:+NzK2A6AOJmnKOVXPOvc+ikbQj0= Xref: csiph.com comp.lang.c:169236 Jorgen Grahn writes: > On Fri, 2023-01-20, Thiago Adams wrote: [...] >> Do you have structs passed by copy in your code? > > Yes, a lot. I don't write C these days, but last time I got to design > new C code, in 2014 or so, I used the feature heavily, to get some > properties I'd normally get from C++. I think call by value is one of > the great things about the C family of languages. > >> Could it be replaced by const * ? > > No. Could you expand on that? I would think that any instance of passing a struct by copy could be straightforwardly replaced by passing it by const*, assuming your able to modify both the caller and the callee. I'm not suggesting that this *should* be done, but you seem to be saying that it *couldn't*. (I could be a good idea for large structs.) [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */