Question
Nicola Sartore · Sep 16

Passing object to a function in objectscript

Let's consider these two ways of passing an obj to a function:

//var is a structured obj
(1) do ..methodX(var)
(2) do ..methodX(.var)

In c++ if we pass an obj by reference like in (2) we save a lot in computation because we are not copying the whole object, and when the object is modified within the function it is modified also for everyone.

In this case does (2) achieve any better performance than (1)? Is passing with the "." save any computation? the object is copied anyway?

Is there a simple way of passing obj to a function?

Product version: IRIS 2021.2
$ZV: InterSystems Studio Client 2021.1.2 Build 338 Server IRIS for UNIX (Red Hat Enterprise Linux for x86-64) 2021.1.2 (Build 336U)
0
0 108
Discussion (3)2
Log in or sign up to continue

var from your sample is not an object in ObjectScript. It is an object reference.

So in first case you pass object reference by value.
In second case you pass object reference by reference. That is reference to object reference.

I don't think you should expect noticeably better performance

So when you create an object in objectscript you always work implicitly with its reference?