[ImageJ-devel] Progress on the Beanshell/macro front

Curtis Rueden ctrueden at wisc.edu
Wed Sep 14 17:12:35 CDT 2011


Hi Wayne,

Why would you want to base the macro interpreter on Beanshell? This is going
> to require a *lot* of work and the resulting Beanshell-based language is
> unlikely to be 100% backward compatible. I thought the plan for handling
> backward compatibility was to hand off legacy macros and plugins to IJ1.
>

The plan until recently was indeed to merely support IJ1 macros as-is,
within the legacy layer. That is, existing macros would work as before, but
no new IJ2 functionality would be accessible via macros. However, after
hearing from people about how they would like to see the macro language
truly work in IJ2 (e.g.,
http://imagejdev.org/pipermail/imagej-devel/2011-September/000480.html),
Johannes and I discussed whether another solution might be possible. As
Johannes says, we already have a proof-of-concept Beanshell-based version of
the macro language, so it is looking quite doable right now—not an enormous
effort to develop or maintain. If it turns out to be a huge burden, we can
fall back to our original strategy, but it is worth a try to make IJ2
accessible via macros.

Regards,
Curtis

On Wed, Sep 14, 2011 at 1:58 PM, Johannes Schindelin <schindelin at wisc.edu>wrote:

> Dear Wayne,
>
> [re-Cc:ing the list, since I think that this issue is of broader
> interest.]
>
> On Wed, 14 Sep 2011, Rasband, Wayne (NIH/NIMH) [E] wrote:
>
> > On Sep 14, 2011, at 2:09 AM, Johannes Schindelin wrote:
> >
> > > I now have a proof-of concept of the Macro interpreter based on
> > > Beanshell. Note: it only supports the getDimensions() function for
> > > now. As described earlier, the problem is that that function takes
> > > possibly uninitialized variables by reference rather than values,
> > > which is fully out of line with the syntax of Beanshell (or C or
> > > Java).
> > >
> > > Instead of forking Beanshell, I decided it'd be better to use
> > > javassist to rewrite a few method calls here and there. I also wanted
> > > to make sure that these modifications do not affect Beanshell itself,
> > > and I put a particular focus on making it possible to load the
> > > Beanshell classes before doing the Javassist modifications (because it
> > > would lead to nasty side effects otherwise).
> >
> > Why would you want to base the macro interpreter on Beanshell? This is
> > going to require a *lot* of work and the resulting Beanshell-based
> > language is unlikely to be 100% backward compatible. I thought the plan
> > for handling backward compatibility was to hand off legacy macros and
> > plugins to IJ1.
>
> There are a lot of power users out there who need the macro language to
> exist also in IJ2. So we cannot simply drop it.
>
> But the legacy macros will not handle IJ2 properly. So we need something
> better.
>
> Also, the limitations of the Macro language are rather severe, not being
> able to interact with the Java API. Now is the time to break that barrier.
>
> There is another rather big problem with the Macro language that I'd like
> to address at the same time: the functions of the macro language are not
> available to Java programmers. In many cases, one can work around that by
> adding chunks of Java code (but there is no consistent way how to
> translate calls to macro functions into Java code), but in some cases, it
> is plainly impossible to do the same thing in Java which is very easy in
> macros (because of the use of package-local methods and fields).
>
> As I suggested at multiple occasions, a properly designed macro interface
> should have a 1:1 correspondence in the Java API. Because if you need to
> be able to do something using macros, there is no good reason to believe
> that the same functionality should be lacking from the Java-accessible
> API.
>
> With the redesign, there will be finally a Java class that defines all the
> macro functions, so we have that 1:1 correspondence not only in the usage,
> but it will indeed be the very same code performing the actions, so there
> is no room for inconsistencies between macros and plugins.
>
> Yes, it will be a lot of work, but I dare to hope that you will notify me
> whenever you change something in the macro language so that I can take
> care of the IJ2 version thereof.
>
> Unfortunately, given the architecture of the IJ1 Macro interpreter, I do
> not see any chance to modify the IJ1 code such that it naturally
> transforms into the IJ2 Macro interpreter. If you do see such a chance,
> please enlighten me.
>
> Ciao,
> Johannes
>
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagejdev.org
> http://imagejdev.org/mailman/listinfo/imagej-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20110914/5957ec7c/attachment.html>


More information about the ImageJ-devel mailing list