3 ms·
Nobody is debating what the word "reference" means. The debate is that "pass-by-reference" is already a different thing from passing something __as__ a referenc
by lvh 10y ago
Nobody is debating what the word "reference" means. The debate is that "pass-by-reference" is already a different thing from passing something __as__ a reference.
I appreciate that it's confusing to someone who isn't familiar with the term, but so's most of CS. We had a term and it referred to a thing, and having it refer to two different things is worse.
- kstenerud 10y agoAnd yet this is the reality we live in. No matter how much talk of "should", the reality stares you implacably in the face. This is a UX problem. Practically speaking, the most important concept is that of cost, which the naive answer covers. The distinction only matters in a language that actually differentiates the two. Otherwise it's little more than trivia, and certainly nothing to get worked up over.
- ivanbakel 10y agoThe difference between pass-as-reference and pass-by-reference is more than trivia - if you were ignorant of it in a language, you might find trouble in the future when a function decides to alter its argument values in a way that negatively affects the caller. Part of the reason we should work to clarify the language is to avoid misconceptions about behaviour based on what kind of "reference" is meant.
- tetromino_ 10y agoA language with pointers also allows a function to alter its logical (not syntactical) argument values in a way that negatively affects the caller. There isn't much practical difference between using // void c_func_alters_deref_pfoo(Foo * pfoo) Foo foo = { ... }; c_func_alters_deref_pfoo(&foo); and // void cpp_func_alters_foo(Foo & foo) Foo foo = { ... }; cpp_func_alters_foo(foo); besides the ability to pass null or otherwise invalid pointers in the C-style version, which can (depending on situation) either simplify your API or be a source of bugs.
- ivanbakel 10y ago>A language with pointers also allows a function to alter its logical (not syntactical) argument values What's the difference between a logical and syntactical argument?