ITT VIS had several presentations about IDL 8.0 at this week’s IDL User Group Meeting. David Fanning says:
Just one word: Wow!
It appears that the promise of IDL 5 has finally been realized. :-)
David also posted a longer description of the new features, so I won’t go through the laundry list (but I do intend to run through it with some examples when 8.0 is actually released, like I did for 7.1).
But I will discuss a bit the one feature that I have used extensively: operator overloading. This was the main focus of my talk about GPULib with IDL 8.0. The gist is that GPULib variables will be objects and if you are running IDL 8.0+, you can do things like the following:
IDL> a = gpuFindgen(10)
IDL> b = gpuFindgen(10)
IDL> c = a + b
This was easy to implement, just inherit from IDL_Object
and write a method with the special name _overloadPlus
:
function gpuvariable::_overloadPlus, left, right
compile_opt strictarr
return, gpuAdd(left, right)
end
Most operators are supported like +
, -
, /
, *
, MOD
, EQ
, etc., but also including brackets (both on the left side and right side of an assignment) and other special methods used by PRINT
, HELP
, and SIZE
. The dot operator is automatically connected to the getProperty
and setProperty
methods of the class.
Another nice point is that GPULib will not require separate versions for pre-8.0 and post-8.0 versions of IDL. Just write a simple dummy IDL_Object
class. This will allow the code to be compiled in versions of IDL before 8.0 and won’t be found (because the real IDL_Object
is part of IDL’s core and found before any user routines) in versions 8.0+. Of course, only the old procedure or function interfaces are available in versions before 8.0. I’m much more likely to use operator overloading because I can provide extra features for IDL 8.0 users and fall back to a more verbose interface for those who have not upgraded yet.
If you have the tech preview handed out at the meeting or are just interested in some more examples of this, check out these HDF5 classes which make use of operator overloading. The end of the mg_h5.pro
file has a main-level program which shows how to use the classes:
IDL> .run mg_h5
Full disclosure: I work for Tech-X Corporation and have worked on the IDL bindings for GPULib.
February 26th, 2010 at 1:26 pm
Mike,
I tried to run your HDF5 classes, but am apparently missing mg_strmerge.pro. I searched your web page for that, but couldn’t find it. Did I just miss it?
Thanks,
David
February 26th, 2010 at 1:34 pm
Darn it, missed a couple of required routines. I added MG_STRMERGE and its requirements to the .zip file. Try now.
February 26th, 2010 at 6:26 pm
Thanks! Much easier to use now. ;-)
David
March 2nd, 2010 at 2:20 am
Are there any plans when IDL 8.0 will be released?
March 2nd, 2010 at 8:02 am
They said IDL 8.0 would be released around May. While I thought there were a lot of great features, some things (like hashes) weren’t even in the preview build they gave us yet, so there is clearly a fair amount of work to do yet.