Object filenames [message #71890] |
Mon, 26 July 2010 11:01 |
mankoff
Messages: 131 Registered: March 2004
|
Senior Member |
|
|
Hi Group,
Standard IDL syntax is to have an object "foo" in a file called
"foo__define.pro" that contains, perhaps, something like this:
PRO foo__define, class
class = { foo:42, bar:"baz" }
END
And then to instantiate said object like this:
IDL> f = obj_new('foo')
==============================================
Would it be simpler, and does anyone see any negatives, to the
following setup:
1) Rename the file from "foo__define.pro" to "foo.pro"
2) Keep the contents exactly as before
3) Append the following to the bottom:
FUNCTION foo, _EXTRA=e
return, obj_new('foo', _EXTRA=e)
END
4) Instantiate the object with the simpler syntax:
IDL> f = foo()
==============================================
This seems a bit cleaner for an end-user of an object group. Cons are
that you cannot tell that it is an object based on the filename (no
__define), nor when reviewing the code. And you cannot access the
structure of the object as a stand-alone structure by the "f = {foo}"
syntax. As object structures should probably not be accessed directly,
those seem like trivial issues.
-k.
|
|
|