Re: Pass by Reference
- Posted by petelomax Jan 04, 2015
- 2739 views
jimcbrown said...
Earlier, I didn't quite agree that PBR was one of these things, seeing that it was so easily emulated. Looking at dcuny's attempts to wrap wxWidgets in an object-oriented way though, I'm starting to move towards PBR being a necessary feature for OO. (Sure, you can get away with emulated PBR, but the lack of necessary syntax sugar makes things clumsier and introduces more room for programmer error.)
It depends on the implementation. Given a C function
void thing(int *i) {...}Then invoking it using
thing(&count)is fine in my book, but should the compiler take
thing(count)and auto-correct it for you with some kind of implicit type cast, it becomes hideously awful.
Instead of
thing(&i,&j,&k)I will always prefer
{i,j,k} = thing(i,j,k)It expresses the intent much more explicitly and is much more flexible, for instance you could preserve i,j,k and discard the updated values
Pete