1. Pass By Reference OOP Style In PHIX?
- Posted by begin Nov 17, 2018
- 1320 views
hi,
in order to get something like a structure, is it possible to do
https://openeuphoria.org/wiki/view/Pass%20By%20Reference%20OOP%20Style.wc
in phix?
or maybe there is some other EASY way to do some thing like an allocatable/definable structure in PHIX?
Thank you
Richard
2. Re: Pass By Reference OOP Style In PHIX?
- Posted by petelomax Dec 06, 2018
- 1090 views
I would use option 1, "We could use a global variable to stash our data. The variable would be a sequence and we would just have to keep track of the index of the data we want to store in there."
In fact, as I understand it, eumem is itself just a general purpose sequence of exactly that ilk.
The sequence does not have to be "global", a private sequence would be fine, as long as you have enough get/set/etc routines.
The first example that springs to mind is builtins/dict.e, admittedly I smeared the "struct" over trees/treenames/roots/sizes etc but the principle is the same.
Note that those sequences are all private, but there plenty enough routines to add/delete things.
Oh, just realised, I should say that I am not suggesting that dict.e be used for this; what I am saying is that it is an example of this, as in ten dictionaries==ten structs.
A couple of points about debugging: If eumem was not "pseudo" memory, and actually used real pointers to allocated memory, then any ex.err would likely just contain banks of meaningless numbers and debugging would be ten times harder. As it is, when debugging the additional abstraction of the general purpose "ram_space" makes things slightly harder, or perhaps significantly harder should there be dozens of other things all mixed in there also using "ram_space".
Regards, Pete
3. Re: Pass By Reference OOP Style In PHIX?
- Posted by begin Dec 08, 2018
- 1047 views
Thanks for the valuable info pete
Richard