| Deutsch English Français Italiano |
|
<v6r4ju$30oa8$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder9.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.lang.c Subject: =?UTF-8?Q?Re:_technology_discussion_=e2=86=92_does_the_world_need_a?= =?UTF-8?Q?_=22new=22_C_=3f?= Date: Fri, 12 Jul 2024 13:38:37 +0200 Organization: A noiseless patient Spider Lines: 72 Message-ID: <v6r4ju$30oa8$1@dont-email.me> References: <v66eci$2qeee$1@dont-email.me> <v68dsm$37sg2$1@dont-email.me> <87wmlzvfqp.fsf@nosuchdomain.example.com> <v6ard1$3ngh6$4@dont-email.me> <v6b0jv$3nnt6$1@dont-email.me> <87h6d2uox5.fsf@nosuchdomain.example.com> <v6d779$6rk5$2@dont-email.me> <v6e76u$c0i9$1@dont-email.me> <v6esqm$fian$2@dont-email.me> <v6f7vg$hgam$1@dont-email.me> <20240707164747.258@kylheku.com> <v6gl83$s72a$1@dont-email.me> <v6h8ao$ur1v$1@dont-email.me> <v6jhk3$1drd6$1@dont-email.me> <v6jiud$1dsjb$1@dont-email.me> <877cdur1z9.fsf@bsb.me.uk> <v6joi4$1epoj$1@dont-email.me> <871q42qy33.fsf@bsb.me.uk> <v6k6i0$1h4d3$1@dont-email.me> <87ed82p28y.fsf@bsb.me.uk> <v6m03l$1tf05$1@dont-email.me> <87r0c1nzjj.fsf@bsb.me.uk> <v6m7ae$1v125$1@dont-email.me> <v6ma1d$1vfv2$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 12 Jul 2024 13:38:38 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a6734a7b2fad055ebe0e6fdde4dcafc6"; logging-data="3170632"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EkwKWr4+sFURjXwasY+5/" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:nIDvogbIVo4r6SGhCo4EMi6t9OI= X-Enigmail-Draft-Status: N1110 In-Reply-To: <v6ma1d$1vfv2$1@dont-email.me> Bytes: 4962 On 10.07.2024 17:40, bart wrote: > On 10/07/2024 15:54, Janis Papanagnou wrote: > >> Values passed (including values of pointers [used for arrays]) are >> handled (in the functions) as copies and cannot change the original >> entities (values or dereferenced objects) in the calling environment. >> >> To make it possible to change entities in the calling environment >> in "C" you have to implement the necessary indirection by pointers. > > > You don't have to do anything at all: > [ snip source code ] What you've coded is to change an entity that is implicitly passed to the function through a pointer. (Don't you understand that?) The indirection is achieved through passing a pointer value, and a copy of that pointer value is available in the function to address the data pointed to. That passed pointer is passed by value (which is the only parameter passing mechanism in "C"). An implicit indirection does not make the parameter passing magically a "call by reference" (even if it appears so to the uninformed; like you). > Here it looks superficially as though 'v' is passed by value (and it is > of a size that the ABI /would/ pass by value), yet F changes its > caller's data, perhaps unintentionally. Any indirection through pointers passed (by "call-by-value"!) to some function will make it possible change the pointed to original items in the calling environment. Because the pointer is pointing to (referring to) the original item does not mean that there's a "call-by-reference" mechanism; in "C" there is no such mechanism. > >> Your insistence is amazing. > /I/ am amazed at everyone's insistence that there is nothing remarkable > about this, and that it is nothing at all like pass-by-reference. Because passing arguments "by reference" is a well established technical mechanism with the term having a specific meaning. If you think you can change semantics of that term, or if you will introduce non-standard phrases like "real call by reference" for "call by reference" only to misuse the term for your own agenda that will not only complicate communication; it's plain wrong and will at best muddy the matter and confuse uninformed readers. Please be so kind and use the established terms here and don't misuse them (to fit your own mental universe or whatever). > > So, how do I write F in C so that the caller's data is unchanged? I wonder why you don't know or haven't yet understood that if you pass pointers that point to any data you can change that original data through the pointer. You cannot prevent that (i.e. not by the means we're discussing here). > > Sure, true pass-by-reference has some extra properties, There is no such thing as "true pass-by-reference"; that's called "pass-by-reference", and it has a well known meaning and semantic. If you want to (mis-)use that well-defined term for a mechanism where pointer-values are passed you are just confusing uninformed readers (and likely anger informed ones). Janis > [...]