IDL 8.4: Variable attributes and static methods
posted Tue 25 Nov 2014 by Michael Galloy under IDL, ObjectsThe biggest change introduced by IDL 8.4 is the treatment of all variables as objects. Every variable now has attributes that you would normally get returned from the SIZE
function: length
, ndim
, dim
, tname
, typecode
, and typename
. For example:
IDL> a = bindgen(2, 3)
IDL> print, a.length
6
IDL> print, a.ndim
2
IDL> print, a.dim
2 3
IDL> print, a.tname
BYTE
There are also static methods available for all variables:
IDL> n = 50
IDL> print, n->toString()
50
Strings, numbers, integers, and pointers have their own set of special methods appropriate for their respective types. For example integers have some handle base conversion methods:
IDL> print, n->toHex()
32
IDL> print, n->toBinary()
110010
Strings have some methods that are not available through other IDL library routines, including the very useful replace
method:
IDL> s = 'ITT VIS'
IDL> print, s.replace('ITT', 'Exelis')
Exelis VIS
November 25th, 2014 at 10:04 am
I haven’t gotten 8.4 installed yet, have you noticed if treating variables as objects has impacted performance at all? They seem like nice additions, but I’d hate to sacrifice run time for convenient syntax.
December 1st, 2014 at 9:19 am
I have not done any speed testing.