Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: bart Newsgroups: comp.lang.c Subject: =?UTF-8?Q?Re=3A_technology_discussion_=E2=86=92_does_the_world_need?= =?UTF-8?B?IGEgIm5ldyIgQyA/?= Date: Wed, 10 Jul 2024 17:48:57 +0100 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: <87wmlzvfqp.fsf@nosuchdomain.example.com> <87h6d2uox5.fsf@nosuchdomain.example.com> <20240707164747.258@kylheku.com> <877cdur1z9.fsf@bsb.me.uk> <871q42qy33.fsf@bsb.me.uk> <87ed82p28y.fsf@bsb.me.uk> <87r0c1nzjj.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 10 Jul 2024 18:48:57 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ded9e1848a26cfa2c70264cde0490f0f"; logging-data="2102600"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nU4Zgqq2DXrsEcZPzz7dR" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:TdRMcP6nU++dT46kWgOK5kIfntc= In-Reply-To: Content-Language: en-GB Bytes: 3241 On 10/07/2024 16:54, James Kuyper wrote: > On 10.07.2024 16:49, bart wrote: > ... >> "So if arrays aren't passed by value in C, and they aren't passed by >> reference, then how the hell ARE they passed?!" > > The problem with that question is the same as the problem with the > question "How are Justices of the US Supreme Court elected?". They > aren't elected, so the question cannot be answered. Arrays cannot be > passed in C, so the question of how they are passed also cannot be answered. > > You can pass a pointer to the start of an array or a pointer to the > whole array; either way, How is that interestingly different from pass-by-reference? Which as you know involves a pointer to the value of an object, so the values are not passed, only the value of the pointer. (You may also know that every language will use pass-by-value for everything if you delve deeply enough.) In C, if you have this char[4] array at this address: 01003F8 65 66 67 00 and try to pass it to a function defined with a char[4] argument, it will end up passing the address 01003F8. If I pass the same array in a similar language but using explicit pass-by-reference, it will also pass the address 01003F8. So, if you were to examine the machine code of such a program which was generated from one of those two languages, could you tell whether it was from the one with true pass-by-reference, or from C which only has pass-by-value?