Appending to List elements

The Jacl lappend method for appending List data structures require List parameters and not Strings parameters when converting to Jython scripts. Using Strings parameters when appending to Jython List elements causes incorrect runtime results when running the preliminary converted Jython script. In the Jacl scripting language, when you are appending to a List using either lappend, the + or the += operators, the appending data structure should be a List element. Although, the Jacl runtime does behave correctly when you append multiple Strings this is because of its internal implementation of lists. However, the Jython scripting language is more strict in its expectation such that only another List or a String which is automatically converted to a List element should be appended.
The following examples correctly appends to List elements and runtime results are maintained between the conversion between the Jacl to Jython syntax:
JACL:   lappend  $x $y
JACL:   lappend  $x [list "aa" bb $cc]
JACL:   lappend  $x "aa" #automatically converted to list element
==>
JYTHON: x.append(y)
JYTHON: x.append(["aa", "bb", cc])
JYTHON: x.append("aa") #automatically converted to list element
The Jacl2Jython program detects and marks the incorrect use of multiple parameters in the Jacl lappend method during the conversion. The Jython append method supports only a single parameter:
JACL:   lappend  $x $y extra
JACL:   lappend  $x "aa" bb extra
==>
JYTHON: x.append(y, "extra") #?PROBLEM? NUM_ARGS!=2
JYTHON: x.append("aa", "bb", "extra") #?PROBLEM? NUM_ARGS!=2?
Note: If your Jacl script is using the += operator to append a String to a List, although converted Jython is syntactically valid, it appends the list of character strings to the end of the list. The following variations all work as expected:
JYTHON: list += moreLists
JYTHON: list = list + string
JYTHON: list.append(string)
JYTHON: list += [string]
The following script which is syntactically correct, but behaves incorrectly at Jython runtime:
JYTHON: list += string  # INCORRECT.  This statement appends a list of characters.
In summary, scan your converted Jython script to check for all the += operator used. If you intend to add a String to a List, change the statement to list += [string]

Feedback