Added Jython solution

Added abstract interface specification.
(Motivation is in the abstract)
This commit is contained in:
Moshe Zadka 2000-11-02 23:53:51 +00:00
parent 769523d18e
commit 4de28740f7
1 changed files with 14 additions and 6 deletions

View File

@ -20,6 +20,17 @@ Abstract
Python, so users will have control over the output from the Python, so users will have control over the output from the
interactive interpreter. interactive interpreter.
Interface
The current Python solution has worked for many users, and this
should not break it. Therefore, in the default configuration,
nothing will change in the REPL loop. To change the way the
interpreter prints interactively entered expressions, users
will have to rebind sys.displayhook to a callable object.
The result of calling this object with the result of the
interactively entered expression should be print-able,
and this is what will be printed on sys.stdout.
Solution Solution
The bytecode PRINT_EXPR will call sys.displayhook(POP()) The bytecode PRINT_EXPR will call sys.displayhook(POP())
@ -30,16 +41,13 @@ Solution
def displayhook(o): def displayhook(o):
if o is None: if o is None:
return return
__builtin__._ = None
print `o`
__builtin__._ = o __builtin__._ = o
print o
Jython Issues Jython Issues
The author knows too little about Jython, but it is very important The method Py.printResult will be similarily changed.
to be compatible with it. displayhook will have to be added to sys,
but since Jython works with Java bytecodes, the compiler would have
to be changed too, or maybe not.
Barry?
Local Variables: Local Variables: