The following standard IDL operators work directly on object reference variables:
Attempting to use other standard operators on object references results in an error.
Tip: Beginning with IDL 8.0, it is possible to overload some IDL operators so that they invoke a user-defined method rather than performing their normal function. See Object Operator Overloading Overview for details.
Many non-computational functions and procedures in IDL also work with object references, such as SIZE, N_ELEMENTS, HELP, and PRINT.
Object Assignment
Assignment works in the expected manner—assigning an object reference to a variable gives you another variable with the same reference. Hence, after executing the statements:
struct = { cname, data1:0.0 }
A = OBJ_NEW('cname')
B = A
HELP, A, B
IDL prints:
A OBJREF = <ObjHeapVar1(CNAME)>
B OBJREF = <ObjHeapVar1(CNAME)>
Note that both A and B are references to the same object heap variable.
Note: The assignment operator cannot be overridden by a user-defined method.
Object Equality and Inequality
The EQ and NE operators allow you to compare object references to see if they refer to the same object heap variable. For example:
struct = {cname, data:0.0}
A = OBJ_NEW('CNAME')
B = A
C = OBJ_NEW()
PRINT, 'A EQ B: ', A EQ B & $
PRINT, 'A NE B: ', A NE B & $
PRINT, 'A EQ C: ', A EQ C & $
PRINT, 'C EQ NULL: ', C EQ OBJ_NEW() & $
PRINT, 'C NE NULL:', C NE OBJ_NEW()
IDL prints:
A EQ B: 1
A NE B: 0
A EQ C: 0
C EQ NULL: 1
C NE NULL: 0
Note: The EQ and NE operators can be overridden by user-defined methods. See Object Operator Overloading Overview for details.