Var and Self
BlitzMax Forums/BlitzMax Programming/Var and Self
| ||
Hi!Strict Type TTest Field X:Int Method Set(Value:Int) Self.X = Value End Method Method DoAnything() Self.Add(Self, Self) End Method Method Add(Test:TTest Var, Result:TTest Var) Result.X = Self.X+Test.X End Method End Type Global Test:TTest Test = New TTest Test.Set(10) Test.DoAnything() Print Test.X vs. Strict Type TTest Field X:Int Method Set(Value:Int) Self.X = Value End Method Method Add(Test:TTest Var, Result:TTest Var) Result.X = Self.X+Test.X End Method End Type Global Test:TTest Test = New TTest Test.Set(10) Test.Add(Test, Test) Print Test.X Thats silly, becouse I think, that, when I don't use Var, BMax will create a copy of this instance -> slower and more memory usage. cu olli |
| ||
Thats silly, becouse I think, that, when I don't use Var, BMax will create a copy of this instance -> slower and more memory usage. BlitzMAX handles all objects by reference, see the "Objects" section of the Language Reference. |