BeanShell Dynamic Typing

Without an explicit type declaration like
Stringresult, BeanShell
variables can change their type at runtime depending on the object or
data assigned to it. This dynamic typing allows you to write code like
this (if you really wanted to):

// note: no type declaration
result = Macros.input(view, “Type something here.”);
// this is our predefined, current View
result = view;
// this is an “int” (for integer);
// in Java and BeanShell, int is one of a small number
// of “primitive” data types which are not classes
result = 14;

However, if you first declared result to be
type String and and then tried these
reassignments, BeanShell would complain. While avoiding explicit type
declaration makes writing macro code simpler, using them can act as a
check to make sure you are not using the wrong variable type of object
at a later point in your script. It also makes it easier (if you are so
inclined) to take a BeanShell “prototype” and incorporate
it in a Java program.

One last thing before we bury our first macro. The double slashes
in the examples just above signify that everything following them on
that line should be ignored by BeanShell as a comment. As in Java and
C/C++, you can also embed comments in your BeanShell code by setting
them off with pairs of /* */, as in the following
example:

/* This is a long comment that covers several lines
and will be totally ignored by BeanShell regardless of how
many lines it covers */