ExternNode is a typical example of External use to interact with Javaobjects. ExternNode implements Selector and has two methods, print and println. It must be subclassed to implement other methods. The System object defined in Interpretor is an instance of it (thus, System.out.println("") and System.out.print("") calls are correct).
public class ExternNode implements Selector { protected String name; public ExternNode(String name){this.name = name;} public String select(String methodName, Vector args) { if(methodName.equals("print")){ if(args.isEmpty()) { System.out.print(""); return null; } else System.out.print((String)args.firstElement()); return (String)args.firstElement(); } if(methodName.equals("println")){ if(args.isEmpty()) { System.out.println("");return null;} else System.out.println((String)args.firstElement()); return (String)args.firstElement(); } System.out.println("unknown method: "+methodName); return null; } public Selector getObjectInSelectorContext(String name) { if(name.equals("out")) return this; else return null; } }