From: Timothy J. H. <ti...@cs...> - 2004-06-23 17:41:49
|
On Jun 23, 2004, at 12:24 PM, Geoffrey Knauth wrote: > Maybe you could have a Guile compatibility feature, so that users > migrating code from Guile to JScheme wouldn't have to worry about the > difference in syntax. In the long run, one syntax will probably win > out over the other, but it could be a very long time before it's clear > what users prefer. Sometimes I wonder about the feasibility/desirability of building multiple front ends to Scheme, Guile being one of them. In many ways Scheme syntax is one of the least interesting parts of the language. It wouldn't be too hard to build multiple readers for JScheme. For example, you could request a Python syntax REPL or you could load a Scheme file implemented with a Prolog style infix notation, or you could read in a file using a strict R5RS syntax, or a Guile syntax. These readers would provide Scheme with many different "skins" and might provide a way out of the syntax debates, especially if everything eventually is parsed into good old s-expressions. My understanding is that there have been many attempts to popularize LISP by providing alternate syntaxes, but it never seems to take. Nevertheless, it might be worth trying again since JScheme is one of the only LISP implementations that lives fully in the most popular language's runtime environment..... ---Tim--- P.S. I have an Prolog-style operator precedence parser implemented in Scheme ( opparse.scm available from http://interval.sourceforge.net/interval/scheme/giaeval/README.html ) which could easily be modified to provide an infix syntax for Scheme programs, e.g. (define (fib n) (if (< n 3) 1 (+ (fib (- n 1)) (fib (- n 2))))) could be expressed in an infix notation as fib(n) := if (n < 3) then 1 else fib(n-1) + fib(n-2) which parses to the s-expression (:= (fib n) (if (< n 3) (then 1 (else (+ (fib (- n 1)) (fib (- n 2))))))) which can then be translated to standard Scheme by appropriate redefinition of the operators (:= is the define macro, ....) Here the parsing works by defining :=, if, then, else, +, -, < to be binary operators with the appropriate precedence and associativity. This is a common trick in Prolog programming and in fact can be used to completely define the syntax of Prolog programs (and many other languages). > > If JScheme makes this overture to the Guile community, maybe Guile > will reciprocate. > > Done right, users should be able to pick the syntax they like with > minimum pain. > > Geoffrey > -- > Geoffrey S. Knauth | http://knauth.org/gsk > > On Jun 23, 2004, at 10:07, Ken Anderson wrote: > >> You're right, i didn't look closely enough at the example. >> >> I thought it was >> ;;; output page header >> (define (header title) >> #- >> <?xml version="1.0" encoding="utf-8"?> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >> >> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> >> <head> >> <title>#- title -#</title> >> </head> >> -#) >> ) >> (header "foobar") >> >> that is as you nested #-'s you go in and out of string/scheme mode. >> But i think it would be confusing to know which level you were at. >> >> I wouldn't add another quasi string type. I'd make it so people >> could add their own # macro characters. >> >> k >> At 09:29 AM 6/23/2004 -0400, Timothy John Hickey wrote: >> >>> On Jun 23, 2004, at 8:59 AM, Ken Anderson wrote: >>> >>>> http://www.unknownlamer.org/code/guile-web-manual.html >>>> >>>> Guile uses #- ... -# as their quasi string approach. Interesting. >>> >>> But their quasi-string doesn't allow escaping into Scheme in >>> the middle. It seems to be just for quoting long sections of text >>> (like Pythons triple quote """.....""") >>> They can get something similar to full quasi-strings though >>> using string- append, or flatten-and-string-append: >>> >>> (flatten-and-string-append >>> #- <html> >>> <head><title> -# title #- </title></head> >>> <body bgcolor="-# color #-"> >>> <h1>Cool, a -# color #- page</h1> >>> </body> >>> </html> -#) >>> >>> which is equivalent to our approach: >>> >>> #{<html> >>> <head><title> #[ title ]# </title></head> >>> <body bgcolor="#[ color ]#"> >>> <h1>Cool, a #[ color ]# page</h1> >>> </body> >>> </html> }# >>> >>> Our-variant on their approach (not escaping into Scheme) >>> would be >>> >>> (!{} >>> #-{<html> >>> <head><title>}-# title #{ </title></head> >>> <body bgcolor="}# color #{"> >>> <h1>Cool, a }# color #{ page</h1> >>> </body> >>> </html> }#) >>> >>> This makes it a little more clear locally what is a string >>> and what is Scheme and uses our built-in operator >>> !{} == flatten-and-string-append >>> >>> >>> Maybe we should add guile-style quasi-strings to JScheme. >>> It would be easy and the guile approach does have a certain elegance! >>> >>> --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 >> > > > > ------------------------------------------------------- > 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 |