From: Ken A. <kan...@bb...> - 2004-07-19 21:30:30
|
Wow, bug fixes and a patch on your first day of using JScheme! You should be an expert by the end of the week! Some Common Lisper's have asked for features like this. Rather than making this patch, i'd like to make things like the REPL, load, eval, analyze, execute, and read procedures that can be replaced by user's jscheme code. This would let us experiment with different approaches. We should be able to write this in JScheme so you can use it. At 02:54 PM 7/19/2004 -0400, Alan Donovan wrote: >Ken, here's a patch to implement named REPL results, like GDB, e.g. > > > (lambda (x) x) > $1 = (lambda (x) x) > > 3 > $2 = 3 > > ($1 $2) > $3 = 3 > >cheers >alan > > > > >=================================================================== >RCS file: /cvsroot/jscheme/jscheme/src/jsint/Evaluator.java,v >retrieving revision 1.8 >diff -c -w -r1.8 Evaluator.java >*** src/jsint/Evaluator.java 16 Jul 2004 22:02:13 -0000 1.8 >--- src/jsint/Evaluator.java 19 Jul 2004 18:52:17 -0000 >*************** >*** 87,103 **** > System.exit(0); > } > > /** Prompt, read, eval, and write the result. > * Also sets up a catch for any RuntimeExceptions encountered. **/ > public void readEvalWriteLoop(String prompt) { > Object x; > if (!EXIT) > for(;;) { > try { > if (EXIT) break; > output.print(prompt); output.flush(); > if ((x = input.read()) == InputPort.EOF) break; >! U.write(eval(x), output, true); > output.println(); output.flush(); > } catch (Throwable e) { > e.printStackTrace(error); >--- 87,116 ---- > System.exit(0); > } > >+ /** >+ * If true, results of REPL evaluations are named (e.g. $3) for future >+ * reference. >+ */ >+ private static final boolean opt_NAME_REPL_RESULTS = true; >+ > /** Prompt, read, eval, and write the result. > * Also sets up a catch for any RuntimeExceptions encountered. **/ > public void readEvalWriteLoop(String prompt) { > Object x; >+ int count = 0; > if (!EXIT) > for(;;) { > try { > if (EXIT) break; > output.print(prompt); output.flush(); > if ((x = input.read()) == InputPort.EOF) break; >! Object result = eval(x); >! if(opt_NAME_REPL_RESULTS) { >! String name = "$" + (++count); >! output.print(name+" = "); >! interactionEnvironment.setValue(Symbol.intern(name), result); >! } >! U.write(result, output, true); > output.println(); output.flush(); > } catch (Throwable e) { > e.printStackTrace(error); |