//must iterate in a deterministic order over the field names (as specified by FieldName.CalSourceFormComparator)
//so that the function is well-defined in the presence of side effects.
//If f is a field, then recordDictionary.f is the dictionary for use when calling the class method Debug.show on
//the value x.f.
RTRecordValue recordDict = (RTRecordValue)recordDictionary;
RTRecordValue xRecord = (RTRecordValue)x;
int nFields = recordDict.getNFields();
StringBuilder showResult;
//tuple records (with 2 or more fields) are displayed using the parentheses notation where field-names are omitted.
if (recordDict.isTuple2OrMoreRecord()) {
showResult = new StringBuilder("(");
for (int i = 0; i < nFields; ++i) {
if (i > 0) {
showResult.append(", ");
}
RTValue fieldDict = recordDict.getNthValue(i);
RTValue xField = xRecord.getNthValue(i);
//compute "Debug.show fieldDict xField"
//this is just (after inlining Debug.show d = d)
//fieldDict xField
showResult.append(fieldDict.apply(xField).evaluate($ec).getStringValue());
}
showResult.append(")");
} else {
showResult = new StringBuilder("{");
for (int i = 0; i < nFields; ++i) {
if (i > 0) {
showResult.append(", ");
}
RTValue fieldDict = recordDict.getNthValue(i);
RTValue xField = xRecord.getNthValue(i);
//compute "Debug.show fieldDict xField"
//this is just (after inlining Debug.show d = d)
//fieldDict xField
showResult.append(xRecord.getNthFieldName(i)).append(" = ");
showResult.append(fieldDict.apply(xField).evaluate($ec).getStringValue());
}
showResult.append("}");
}