From the interactions pane:
> int i = 3
> int i = 4
Error: Redefinition of 'i'
As the Java language dictates, this is an error. But
since the language used in the interactions pane isn't
*really* Java anyway, why not allow a looser
interpretation of the above code, and simply replace
the old definition of 'i' with a new one?
This error shows up a lot when some mistake is made in
defining a variable. For example:
> MyObject o = [long, complex expression here]
[user notices a mistake in the expression and presses 'up']
> MyObject o = [long, complex, modified expression here]
Error: Redefinition of 'MyObject'
It seems obvious in such cases that the user wants to
bind 'o' to the second instance.
Logged In: YES
user_id=429731
This was extensively discussed and addressed in feature
request 694679:
https://sourceforge.net/tracker/index.php?func=detail&aid=694679&group_id=44253&atid=438938
The current semantics allow you to redefine a variable if
you made a syntax error typing it the first time (which used
to be horribly annoying), but not if you successfully
defined the variable, since that violates Java semantics.
It's true that the Interactions pane isn't exact Java, but
moving further isn't clearly the right thing to do. One
alternative is to provide a config option allowing
redefinition of variables, though crowding the preferences
screen isn't always great either.
Whether this gets implemented or not, it deserves some
active discussion between the developers.