Login  Register

Re: FIJI/IJ2 script editor

Posted by dscho on Jun 19, 2014; 2:54pm
URL: http://imagej.273.s1.nabble.com/FIJI-IJ2-script-editor-tp5008308p5008320.html

Hi Leon,

On Thu, 19 Jun 2014, Leon Espinosa wrote:

> I prefer to repport those problems here because I do not know if this is
> actually the "bugs" or a scheduled behavior of the editor change ...
> Some things do not work and others work differently by compared to
> FIJI/IJ1
>
> in FIJI/IJ2
> IJ.wait(1000);
> in the editor "python" fails
> in the editor javascript fails.
> in the jython interpreter fails
> in the javascript interpreter works OK

Please note that the interpreters will go away unless somebody else puts
in the work to port them to the SciJava scripting framework. (The reason
for SciJava's scripting framework's existence is exactly those
inconsistencies in IJ1's and previous Fiji's scripting which you pointed
out.)

As I just wrote in a mail to Christophe, the auto-imports (which you can
switch on in the script editor, but you should not!) are a dangeours
business. It's sloppy and will bite you *in the future*. When somebody
else introduces classes with the same name, and you will be puzzled no end
why things broke.

> in FIJI/IJ1 javascript and python editor
> IJ.beep();  OK
>
> in FIJI/IJ2 editor javascript
> IJ.beep();  fails
> in FIJI/IJ2 javascript interpreter OK
>
> in FIJI/IJ1 "python" editor
> IJ.beep();  OK
> in FIJI/IJ2 "python" editor
> IJ.beep()   fails
>
> in FIJI/IJ2 "python" editor
> from ij import IJ as IJ
> IJ.beep()    OK
>
> in FIJI/IJ2 "python" interpreter
> IJ.beep()  OK
>
> I was unable to import ij.IJ in the FIJI/IJ2 javascript editor with
> "import ij.IJ.*;"  while  " from ij import IJ as IJ" works with the
> "python" editor...

Yes, Javascript's syntax is a bit funky:

        importClass(Packages.ij.IJ);

Please, for all of our sakes (but especially mine because I want to spend
my time coding instead): use explicit imports all the time! And that
includes very much avoiding wildcard imports (i.e. *no* "import ij.*"!).

If anyone thinks wildcard imports are a Good Thing, I would like to remind
that someone that I had to spend a good 80 hours in total on that stupid
TextField issue with the Volume Viewer. And those issues were only caused
*by the use of wildcard imports*. On the caller's side.

Therefore, do everybody a favor, do not use auto-imports or wildcard
imports. Like, ever.

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html