3 ms·
Aren't reference variables just syntactic sugar on top of pointers? I've seen this debate about pointers vs. references so many times that I'm starting to think
by jobu 9y ago
Aren't reference variables just syntactic sugar on top of pointers? I've seen this debate about pointers vs. references so many times that I'm starting to think I might be missing something.
- fjdlwlv 9y agoYes.
- thinkpad20 9y agoThis has always bugged me too. I don't understand why people make such a big deal about pass-by-value and pass-by-reference when the latter is essentially a small layer of syntactic sugar over the former. Anything you can do with reference variables can be done with pointers, with a few more characters (and arguably easier to read, if you're not used to reference variables), so from a semantic point of view it doesn't add anything new. PBV and PBR seems to be a tiny distinction and yet, we have blog posts and interview questions and online debates about whether a language falls into the first or second category.