Re: New Wiki page Pass By Reference OOP Style
- Posted by _tom (admin) Sep 09, 2015
- 1526 views
A fine article and a working example. We all want to see more!
You could work some of this into your article:
Pass-By-Value: Safe
Arguments in a subroutine are copies of values you pass in. Obviously, making a copy takes time and consumes memory. PBV is slow and inefficient but safe.
Pass-By-Reference: Fast
Arguments in a subroutine are just references to the value you pass in. Obviously, no lost time in making a copy and no extra memory consumed. PBR is fast and efficient but not safe.
oE is PBV Safe and PBR Fast
Pass an argument into a oE subroutine and it behaves like a copy. Changes to the value never alter the value outside the subroutine; oE programming is safe.
Pass an argument into an oE subroutine and it behaves like a reference. No copy is made; you can pass a huge (really huge) argment to a subroutine without a speed or memory penalty; oE programming is fast.
What is going on? oE makes copies of just what it needs inside a subroutine and maintains references back to the original as required. But, the original is never altered unless you explicitly assign a value to it.
Passing arguments in oE is fast, efficient, and safe.
_tom