From: Timothy J. H. <tim...@ma...> - 2004-06-24 04:06:25
|
On Jun 23, 2004, at 6:35 PM, Ken Anderson wrote: > I think the idea that JScheme is an alternative "skin" for java > programs is an important one, and your idea of allowing alternative > languages to provide java behavior by using JScheme as a back end is a > good one. > > We could support multiple syntax by allowing a customizable #macro, or > as Common Lisp did, allow a customizable (read) so you could change > its read-table. One way to allowing multiple syntaxes is just provide a reader (stream->s-expressions+errors) and then to provide a way of setting the reader for a JScheme instance. For example, one might say > (define js (jscheme.JScheme.)) ;; create a JScheme instance > (.setReader js infix-reader) ;; set its reader to infix > (.eval js #{ square(x) := x*x }#) ;; define the square function > (let ((z (.eval js 'square))) ;; grab that function and apply it to 35 (z 35)) > (.setReader js norvig-reader) ;; now set the reader to norvig-reader > (.eval js #{ define(sq(x),*(x,x)) }# ) ;; define square with this syntax ;; note that define is a macro which operates after reading... > ((.eval js 'sq) 35) ;; apply it, > (.REPL js) ;; now start a norvig-reader REPL ... > define(fib(n),if(<(n,3),1,+(fib(-(n,1)),fib(-(n,2))))) > fib(10) > exit() > > > After TCL/TK came out Stallman i believe criticized it for being a bad > scripting language, because string hacking was everywhere, especially > in the inner loop. > He said something like "translate TCL into Scheme and win big". I > believe the outcome was that the people who tried to translate TCL > into Scheme had to make semantic changes to TCL for things to work > out, much as PLT Scheme needs changes to Python for their analysis to > be userful. This might not be a bad thing if one is thinking of creating a new language that combines Python syntax and Scheme semantics.... > I'm sure that the amount of effort provided from the Scheme side to > the other language was substantial. > > Eventually, someone wrote a TCL "compiler" that ran at about as well > as the Scheme implementation. Which just proves that bad ideas will > continue to win as long as someone is willing to put more effort into > them. > > While you can translate the code into Scheme, its harder to translate > the error messages. True... > Why am i getting a JScheme and Java backtracke when i'm talking to > prolog? I was actually thinking about defining new readers for Scheme so the syntax would be infix (or operator/precedence/associativity) but the semantics would be Scheme. The idea about compiling language L into Scheme is interesting too but much more complex, I was thinking more about low hanging fruit. I think Peter Norvig once said that he provided a LISP reader that converted F(A,B,...,Z) to (F A B ... Z) and won some converts to Scheme on that simple change alone, e.g. define( fib(n), if( <(n,3), 1, +( fib(-(n,1)), fib(-(n,2))))) This makes it look like a non-LISP syntax, but its really just a slight twist on s-expressions. > We can hide this to some extent, but to provide "good" language > specific runtime error message may be hard. Of course, the JScheme > attitude should be, that that doesn't make it worth trying! JScheme - > you can get a lot more than you might expect from a little language. Moreover, it may be worthwhile creating a Python-like language which looks like Python but compiles to Scheme, or a Java-like language that compiles to Scheme... Another alternative is just to explore clean interfaces between Java versions of Python, Ruby, Prolog, etc. and use JScheme to be the glue that holds them all together. (When I get some time I want to create a SISC procedure for invoking JScheme eval, this would allow users of SISC to have full access to JScheme and the javadot notation. Likewise, providing links from Jython, JRuby, and Java versions of Prolog would be interesting too.....) ---Tim--- > > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |