From: Ken A. <kan...@bb...> - 2004-05-19 22:16:01
|
I don't think SchemeEvaluator is pulling it's weight. It has no methods and the only thing it really does is cause a runtime coersion in JS. I'd just change things to use Evaluator for now, though we could make Evaluator abstract and use jsint.EvaluatorImpl. k |
From: Toby A. <tob...@pe...> - 2004-05-19 22:25:59
|
On Wed, May 19, 2004 at 06:15:28PM -0400, Ken Anderson wrote: > I don't think SchemeEvaluator is pulling it's weight. It has no > methods and the only thing it really does is cause a runtime coersion > in JS. > > I'd just change things to use Evaluator for now, though we could make > Evaluator abstract and use jsint.EvaluatorImpl. Agreed, it serves no useful purpose presently. I put it there to avoid exposing jsint classes in the interface of jscheme.JS, which seemed to be the general pattern, and I couldn't think of any useful methods to expose at that level. Toby. P.S. Thanks for accepting my changes, it really makes my life a lot easier! |
From: Ken A. <kan...@bb...> - 2004-05-19 22:45:46
|
Yes, The original code didn't worry about interfaces. But Tim added them. But we never followed through with it. We need to define SchemeEvaluator to have all the abstract methods we need in Evaluator and then use SchemeEvaluator everywhere except where we new an Evaluator. Actually lets reverse that. Evaluator is an interface, or abstract class, and jsint.EvaluatorImpl is the implementation. Some days, i just miss Common Lisp. k At 10:25 AM 5/20/2004 +1200, Toby Allsopp wrote: >On Wed, May 19, 2004 at 06:15:28PM -0400, Ken Anderson wrote: >> I don't think SchemeEvaluator is pulling it's weight. It has no >> methods and the only thing it really does is cause a runtime coersion >> in JS. >> >> I'd just change things to use Evaluator for now, though we could make >> Evaluator abstract and use jsint.EvaluatorImpl. > >Agreed, it serves no useful purpose presently. I put it there to avoid >exposing jsint classes in the interface of jscheme.JS, which seemed to >be the general pattern, and I couldn't think of any useful methods to >expose at that level. > >Toby. > >P.S. Thanks for accepting my changes, it really makes my life a lot >easier! |
From: Timothy J. H. <tim...@ma...> - 2004-05-20 02:30:10
|
On May 19, 2004, at 6:45 PM, Ken Anderson wrote: > Yes, The original code didn't worry about interfaces. But Tim added > them. My idea was to put things in the "jscheme" package that were not likely to change (e.g. the jscheme.REPL.java class) and to refrain from directly using anything in jsint since those classes were more likely to change (as in fact we have just done in refactoring Scheme.java using Toby's Evaluator class). My preference would be to keep continue this separation.... long-lived features go into jscheme classes, features likely to change go into jsint with some simple interface in jscheme. > > But we never followed through with it. We need to define > SchemeEvaluator to have all the abstract methods we need in Evaluator > and then use SchemeEvaluator everywhere except where we new an > Evaluator. > > Actually lets reverse that. Evaluator is an interface, or abstract > class, and jsint.EvaluatorImpl is the implementation. Yes. In that case, we could move parts of Evaluator into jscheme. > > Some days, i just miss Common Lisp. Some day, I think a descendant of LISP and Java will be the dominant programming language (and maybe Jscheme will play a role in that evolution....) > k > At 10:25 AM 5/20/2004 +1200, Toby Allsopp wrote: >> On Wed, May 19, 2004 at 06:15:28PM -0400, Ken Anderson wrote: >>> I don't think SchemeEvaluator is pulling it's weight. It has no >>> methods and the only thing it really does is cause a runtime coersion >>> in JS. >>> >>> I'd just change things to use Evaluator for now, though we could make >>> Evaluator abstract and use jsint.EvaluatorImpl. >> >> Agreed, it serves no useful purpose presently. I put it there to >> avoid >> exposing jsint classes in the interface of jscheme.JS, which seemed to >> be the general pattern, You're right, that is the general pattern... >> and I couldn't think of any useful methods to >> expose at that level. >> >> Toby. >> >> P.S. Thanks for accepting my changes, it really makes my life a lot >> easier! What applications are you working on that require (or call for....) these changes? ---Tim--- > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle > 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |
From: Toby A. <tob...@pe...> - 2004-05-20 20:53:57
|
On Wed, May 19, 2004 at 10:29:57PM -0400, Timothy John Hickey wrote: > > Some days, i just miss Common Lisp. > > Some day, I think a descendant of LISP and Java will be the dominant > programming language (and maybe Jscheme will play a role in that > evolution....) I must say that after discovering Lisp it's painful to have to write Java. I don't have a lot of faith that the software industry will adopt the features that make Lisp great any time soon though. Instead people fritter away their time on stuff like Groovy :-( > > > P.S. Thanks for accepting my changes, it really makes my life a > > > lot easier! > > What applications are you working on that require (or call for....) > these changes? I want to be able to run arbitrary code inside an EJB that is deployed on a running server without having to go through the whole compile-deploy cycle. The big idea is to make our J2EE application scriptable, but the actual application that I'm using it for is unit testing. The requirement to have multiple threads executing independent Scheme programs comes from the possibility that multiple client programs could connect to our application and ask to run Scheme code simultaneously and it would be bad if they interfered with each other. Toby. |
From: Ken A. <kan...@bb...> - 2004-05-20 21:23:12
|
At 08:53 AM 5/21/2004 +1200, Toby Allsopp wrote: >On Wed, May 19, 2004 at 10:29:57PM -0400, Timothy John Hickey wrote: >> > Some days, i just miss Common Lisp. >> >> Some day, I think a descendant of LISP and Java will be the dominant >> programming language (and maybe Jscheme will play a role in that >> evolution....) > >I must say that after discovering Lisp it's painful to have to write >Java. I don't have a lot of faith that the software industry will adopt >the features that make Lisp great any time soon though. Instead people >fritter away their time on stuff like Groovy :-( If you want a bad programming experience try this http://fishbowl.pastiche.org/2002/10/09/xml_is_not_a_programming_language The examples line are from an object oriented xml language o:xml their website http://www.o-xml.org/ says: "Welcome to the o:XML web site, home of one of the most innovative and promising new technologies available today" It has multiple inheritance, so if you strip away the syntax you might have lisp. >> > > P.S. Thanks for accepting my changes, it really makes my life a >> > > lot easier! >> >> What applications are you working on that require (or call for....) >> these changes? > >I want to be able to run arbitrary code inside an EJB that is deployed >on a running server without having to go through the whole >compile-deploy cycle. The big idea is to make our J2EE application >scriptable, but the actual application that I'm using it for is unit >testing. > >The requirement to have multiple threads executing independent Scheme >programs comes from the possibility that multiple client programs could >connect to our application and ask to run Scheme code simultaneously and >it would be bad if they interfered with each other. I guess in web applications we get around this because each page gets its own class loader and the multiple JScheme instances don't see each other. I'm suprised J2EE doesn't work that way too. JScheme is nice for testing. I have code that lets you write JUnit tests in JScheme. Maybe i should check it in. One nice thing is you can write JScheme code to generate tests for you from a pile of input - output examples. k |
From: Timothy J. H. <tim...@ma...> - 2004-05-20 22:57:32
|
On May 20, 2004, at 4:53 PM, Toby Allsopp wrote: > On Wed, May 19, 2004 at 10:29:57PM -0400, Timothy John Hickey wrote: >>> Some days, i just miss Common Lisp. >> >> Some day, I think a descendant of LISP and Java will be the dominant >> programming language (and maybe Jscheme will play a role in that >> evolution....) > > I must say that after discovering Lisp it's painful to have to write > Java. I agree, though I actually like the JVM and all of the Java libraries and applications. With the new jscheme.JScheme class, I think we can easily wrap Jscheme code in a Java class in such a way that noone need know it is written in Scheme. You just create a static JScheme instance "js" as a private static variable, load in the code, and then use js to provide functionality to all of the methods and initializers of the class.... It might be nice to create a JScheme->Java compiler that produced reasonable looking Java code, that would remove some of the "management impediments" to using JScheme in the workplace. > I don't have a lot of faith that the software industry will adopt > the features that make Lisp great any time soon though. Not soon, but I think the movement toward many of the Scheme features is inevitable (closures, higher order functions, simplicity in syntax and semantics). > Instead people > fritter away their time on stuff like Groovy :-( I was blissfully unaware of Groovy..... > >>>> P.S. Thanks for accepting my changes, it really makes my life a >>>> lot easier! >> >> What applications are you working on that require (or call for....) >> these changes? > > I want to be able to run arbitrary code inside an EJB that is deployed > on a running server without having to go through the whole > compile-deploy cycle. Yes! Great idea. I use Scheme to write webapps that have that same flavor. When a browser selects a file with the .servlet suffix, the scheme webapp reads the scheme code in that servlet, evaluates it in an environment containing the request, response, and httpservlet parameters and returns the result. It makes it very easy to develop servlets, just change the scheme code in the .servlet files.... debugging is pretty easy as well as we can send the error messages to the browser when in debug mode.... > The big idea is to make our J2EE application > scriptable, but the actual application that I'm using it for is unit > testing. Please keep us posted. Its nice to have interesting examples to help drive development.... > > The requirement to have multiple threads executing independent Scheme > programs comes from the possibility that multiple client programs could > connect to our application and ask to run Scheme code simultaneously > and > it would be bad if they interfered with each other. I understand, and I think there will be many other benefits of this extension (such as the ability to wrap Scheme code in Java classes as discussed above). ---Tim--- > > Toby. > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle > 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |
From: Anton v. S. <an...@ap...> - 2004-05-20 23:43:49
|
Timothy John Hickey wrote: > It might be nice to create a JScheme->Java compiler that produced > reasonable looking Java code, that would remove some of the "management > impediments" to using JScheme in the workplace. Yes, I was jealous when I saw Linj: http://www.evaluator.pt/linj.html (Jealous because I want to be able to do that with Scheme) Anton |
From: Toby A. <tob...@pe...> - 2004-05-21 02:17:58
|
On Thu, May 20, 2004 at 06:57:27PM -0400, Timothy John Hickey wrote: > On May 20, 2004, at 4:53 PM, Toby Allsopp wrote: > > I must say that after discovering Lisp it's painful to have to write > > Java. > > I agree, though I actually like the JVM and all of the Java libraries > and applications. With the new jscheme.JScheme class, I think we can > easily wrap Jscheme code in a Java class in such a way that noone need > know it is written in Scheme. You just create a static JScheme > instance "js" as a private static variable, load in the code, and then > use js to provide functionality to all of the methods and initializers > of the class.... Interesting idea, but wouldn't you have to have all your Scheme code in strings? I suppose you could ship a .scm file along with the .class, but then it's a bit of a giveaway that you're using Scheme. > It might be nice to create a JScheme->Java compiler that produced > reasonable looking Java code, that would remove some of the > "management impediments" to using JScheme in the workplace. Have you seen Linj (http://www.evaluator.pt/downloads/tutorial.html)? It's not Free, but is free for non-commercial use and aims to solve that exact problem. > > I don't have a lot of faith that the software industry will adopt > > the features that make Lisp great any time soon though. > > Not soon, but I think the movement toward many of the Scheme features > is inevitable (closures, higher order functions, simplicity in syntax > and semantics). I agree about closures and HOFs, but I don't see any movement towards simple syntax or semantics. I suppose Java is better than C++ in that regard, but it's slowly getting worse (generics, new for syntax). > > Instead people fritter away their time on stuff like Groovy :-( > > I was blissfully unaware of Groovy..... Sorry to have ruined your day :-) > > I want to be able to run arbitrary code inside an EJB that is > > deployed on a running server without having to go through the whole > > compile-deploy cycle. > > Yes! > Great idea. > I use Scheme to write webapps that have that same flavor. When a > browser selects a file with the .servlet suffix, the scheme webapp > reads the scheme code in that servlet, evaluates it in an environment > containing the request, response, and httpservlet parameters and > returns the result. > > It makes it very easy to develop servlets, just change the scheme code > in the .servlet files.... debugging is pretty easy as well as we can > send the error messages to the browser when in debug mode.... Sounds like JSP, although with the distinct advantage of being Scheme rather than JSP :-) Toby. |
From: Timothy J. H. <ti...@cs...> - 2004-05-21 17:24:22
Attachments:
GroupServerW.java
GroupServer.scm
|
I think this recent change to JScheme (adding the jscheme.JScheme class), finally allows us to create Java libraries in Scheme using a very simple wrapping technique. Before this change there was always the possibility that some other class could interfere with the classes JScheme environment and hence the libraries would be particularly fragile. The ability to generate multiple independent interpreters makes that problem go away. I've started building some libraries this way (an example is below) and it is actually quite nice. Assuming we package everything in a jar (including the Scheme code) and that people download the jar and consult the javadoc for instructions on how to use the package, only those who look closely at the source will know that there is any Scheme involved at all... On May 20, 2004, at 10:17 PM, Toby Allsopp wrote: > On Thu, May 20, 2004 at 06:57:27PM -0400, Timothy John Hickey wrote: >> On May 20, 2004, at 4:53 PM, Toby Allsopp wrote: >>> I must say that after discovering Lisp it's painful to have to write >>> Java. >> >> I agree, though I actually like the JVM and all of the Java libraries >> and applications. With the new jscheme.JScheme class, I think we can >> easily wrap Jscheme code in a Java class in such a way that no-one >> need >> know it is written in Scheme. You just create a static JScheme >> instance "js" as a private static variable, load in the code, and then >> use js to provide functionality to all of the methods and initializers >> of the class.... > > Interesting idea, but wouldn't you have to have all your Scheme code in > strings? I suppose you could ship a .scm file along with the .class, > but then it's a bit of a giveaway that you're using Scheme. > I actually don't mind if they know it was written using Scheme (in an open source world thats in fact required). I'm more interested in them being able to easily write Java classes with all of the functionality given by Scheme code. This raises the issue of what the scope of the JScheme instance should be. Should it be defined for each instance of the class, or should there be one for all instances of the class. Here's an example of a wrapping of some of the functionality of the groupscheme/test/GroupServer.scm module from groupscheme.sourceforge.net which works nicely.... > package groupdemo; > > public class GroupServerW { > // create a static JScheme instance for use by this class > // and initialize it to use the GroupServer module > static jscheme.JScheme js = null; > static { > js = new jscheme.JScheme(); > js.eval("(use-module {groupscheme/test/GroupServer.scm})"); > } > > jscheme.SchemeProcedure groupserver=null; > > public GroupServerW(int port) { > groupserver= > (jscheme.SchemeProcedure) > js.call("make-group-server", > new Integer(port)); } > > public void quit() { > js.call(groupserver,js.eval("'quit")); } > > public static void main(String[] args) { > js.call("main",args); } > } This is the usual verbose Java boilerplate, but the nice thing is that all of the real content is in the Scheme code accessed by js.call or js.eval expressions. Adding the javadoc can be thought of as a way of commenting the Scheme code and making it into a library for use by other Java or JScheme programmers.... and here is the code with some javadoc comments .... |
From: Ken A. <kan...@bb...> - 2004-05-21 18:02:48
|
Very clever! I've been thinking it should be possible to do some simple type inference on simple Scheme procedures like the methods in your example, so maybe we could generate this code somehow. k |
From: Rahul <Rah...@Su...> - 2004-05-21 21:09:26
|
Hi, i've not posted here before but i've been a long time user of jscheme. thought i should share these .. I used jscheme to a very large extent in my last project [i've just joined another firm]. [An administration interface for a webapplication that runs over tomcat.] while I had a lot of trouble to get the management to accept jscheme [I did a prototype with most of the functionality they needed] I encountered the highest resistance from Developers. [Mostly due to the fact that it was neither jsp nor xslt which they were familiar with] coupled withe the reputation of scheme as an academic language, not for real world .. it was really interesting to argue the case :) . One interesting point which they pointed out was also that , our application was javascript intensive, and the amount of escaping that we needed to introduce for the curly braces made it look quite ugly. [We were able to solve the prob partly by linking the js from outside but for the left over script portions the problem still remained.] Since Jscheme has targeted the webplatform and javascript is one of the beasts that we are likely to encounter very often in that arena, it would be nice to have some way of toggling the string delimiters with some other strings. Other than that I was able to convert some of my dev friends into users of jscheme [the turning point came due to jscheme's ability to easily inspect and modify internal variables which came in real handy while trying to debug live servers where QA had demonstrated elusive bugs.] JScheme's ability to work with java with out any scaffolding [and the dot notation is really helpful] was real handy and also helped in the conversions :). These are the details of the project that I worked in: [ Quark Web Application Framework -- It is used as the underlying container for Quark's [http://www.quark.com] enterprise products] The rest of the products based on QWAF extends the admin interface thru jscheme. QMP [http://www.quark.com/products/quarkdms/modules/media_portal] QDM [http://www.quark.com/products/quarkdds/overview_modules.html] --A kind of proxy for our custom requests built using the same application also uses it quite heavily. Thanks a lot for jscheme.. ~Rahul -- blufox.batcave.net /*With eyes that speak of the Stars, and magick my very soul, A Dragon I am Eternal.*/ |
From: Timothy J. H. <tim...@ma...> - 2004-05-21 23:12:12
|
On May 21, 2004, at 5:06 PM, Rahul wrote: > Hi, > > i've not posted here before but i've been a long time user of > jscheme. thought i should share these .. Its always nice to hear from other JScheme users... > > I used jscheme to a very large extent in my last project [i've just > joined another firm]. > > [An administration interface for a webapplication that runs over > tomcat.] > while I had a lot of trouble to get the management to accept jscheme > [I did a prototype with most of the functionality they needed] > I encountered the highest resistance from Developers. [Mostly due to > the fact that it was neither jsp nor xslt which they were familiar > with] > coupled withe the reputation of scheme as an academic language, not > for real world .. it was really interesting to argue the case :) . When more projects that actually start to use Scheme the arguments will get easier. How does management feel about Scheme now? For example, would they be happy to have a link to their site from the JScheme website talking about a success story? .... or would it be counter productive to advertise the fact? Maybe they would prefer not to advertise the underlying implementation stories.... > > One interesting point which they pointed out was also that , our > application was javascript intensive, and the amount of escaping > that we needed to introduce for the curly braces made it look quite > ugly. [We were able to solve the prob partly by linking the js from > outside but > for the left over script portions the problem still remained.] > > Since Jscheme has targeted the webplatform and javascript is one of > the beasts that we are likely to encounter very often in that arena, > it would be nice to have some way of toggling the string delimiters > with some other strings. That shouldn't be too hard. What delimiters would you suggest? What would you think about some kind of general string delimiter say like this {{+ Here is "some" {javascript} or {CSS} or arrays A[x] or ... and here is a Scheme escape +[(Date.)]+ hmmmm? +}} where the character following the {{ indicates the stop character for the string, in this case + and +[ ]+ would delimit the quasi-string escapes..... So you could equivalently use a period {{. Here is "some" {javascript} or {CSS} or arrays A[x] or ... and here is a Scheme escape .[(Date.)]. hmmmm? .}} or a double quote {{" Here is "some" {javascript} or {CSS} or arrays A[x] or ... and here is a Scheme escape "[(Date.)]" hmmmm? "}} and you could switch midway with each [...] providing an opportunity to switch delimiters. For example, here we switch from " to * to @ {{" Here is "some" {javascript} or {CSS} or arrays A[x] or ... and here is a Scheme escape "[(Date.)]* hmmmm? here is a square bracket "[" see? maybe just switch for fun *[]@ hmmmm.. @}} What do you think? Would this have helped make the code cleaner and the developers happy? What do other JSchemer's think of this notation? Any other ideas for handling the string delimiter problem? > > Other than that I was able to convert some of my dev friends into > users of jscheme [the turning point came due to jscheme's ability to > easily inspect and modify internal variables which came in real handy > while trying to debug live servers where QA had demonstrated elusive > bugs.] Ken is to thank for the nice inspection tools! If thats a selling point, we might want to develop some more tools in that direction ... Its kind of ironic that a system without much of a debugger (JScheme) finds one of its most useful applications is in debugging! Maybe its the power that is uncovered by providing the developer with direct interactive, scriptable access to the running program. > > JScheme's ability to work with java with out any scaffolding [and the > dot notation is really helpful] was real handy and also helped in the > conversions :). Hmmmm. Jscheme as the anti-IDE? > > These are the details of the project that I worked in: > [ Quark Web Application Framework -- It is used as the underlying > container for Quark's [http://www.quark.com] enterprise products] > The rest of the products based on QWAF extends the admin interface > thru jscheme. > QMP [http://www.quark.com/products/quarkdms/modules/media_portal] > QDM [http://www.quark.com/products/quarkdds/overview_modules.html] > --A kind of proxy for our custom requests built using the same > application also uses it quite heavily. Impressive! I love seeing Scheme invisibly present in products! (like the Lisp purportedly in Orbitz) The JScheme zlib/png license certainly helps encourage such uses as it places no major restrictions on its use.... > > Thanks a lot for jscheme.. Thanks for the feedback... The JScheme language/implementation benefits greatly when we get feedback from people using JScheme to build real systems. Both Ken and I are active JScheme users, and many of the people on this list are active users as well. I'd like to thank all the people on this list for their help (and patience) over the years. ---Tim--- > > > > ~Rahul > -- blufox.batcave.net > /*With eyes that speak of the Stars, > and magick my very soul, > A Dragon I am Eternal.*/ > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle > 10g.Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |
From: Ken A. <kan...@bb...> - 2004-05-23 21:11:39
|
Here are two proposals: P1: Use as the quasistring delimiter {{ also inside a quasistring expression {{ starts an escape to Scheme. I think i found this approach in another web application and sent email to the group. The advantage is - you can keep the current syntax, if you only see { and use the new one if you see { - Only one character #\{ becomes special. - I'm guessing that "{{" is uncommon. P2: Common Lisp has a very flexible reader controlled by a read-table. (Once i sat down to work on a Lisp Machine that was reading in ALGOL syntax, boy was i suprised.) One way to extend CL was to add reader-macros that had the form #name where name was the name of a macro, typical one character, like #?. These are extensions of #t #f #(). Providing this facility would let anyone add a way of swithching syntax. For example, Rahul could have solved his javascript problem by using #js{....}, say. This proposal is just to add #... extension capability. P3: I've been interested in rewriting the JScheme (read) in Scheme as a finite state machine, and compile it into Java. This should be relatively easy because we only have a relatively small number of types and operations. This could either implement P2 or the full read-table approach. I guess i've vote for P1 as the easiest thing to do at this point. k At 07:12 PM 5/21/2004 -0400, Timothy John Hickey wrote: >That shouldn't be too hard. What delimiters would you suggest? > > >What would you think about some kind of general string delimiter say >like this > > {{+ Here is "some" {javascript} or {CSS} or arrays A[x] or ... > and here is a Scheme escape +[(Date.)]+ > hmmmm? +}} > >where the character following the > {{ >indicates the stop character for the string, in this case > + >and > +[ ]+ >would delimit the quasi-string escapes..... > >So you could equivalently use a period > > {{. Here is "some" {javascript} or {CSS} or arrays A[x] or ... > and here is a Scheme escape .[(Date.)]. > hmmmm? .}} > >or a double quote > > {{" Here is "some" {javascript} or {CSS} or arrays A[x] or ... > and here is a Scheme escape "[(Date.)]" > hmmmm? "}} > >and you could switch midway with each [...] providing an opportunity >to switch delimiters. For example, here we switch from " to * to @ > > > {{" Here is "some" {javascript} or {CSS} or arrays A[x] or ... > and here is a Scheme escape "[(Date.)]* > hmmmm? here is a square bracket "[" see? > maybe just switch for fun *[]@ hmmmm.. @}} > >What do you think? Would this have helped make the code cleaner >and the developers happy? > >What do other JSchemer's think of this notation? >Any other ideas for handling the string delimiter problem? |
From: Timothy J. H. <tim...@ma...> - 2004-05-24 12:34:11
|
If forgot to remark earlier that I've run into the same problem as Rahul with having to quote curly braces (in the context of writing webpages containing CSS in the head). There is a relatively simple approach to this problem that doesn't require backquoting... The idea is just to escape into a regular quoted string with [" ..... "] e.g. {<html> <head> <title>CSS test</title> <style><!-- [" body {background:rgb(255,255,240); padding:0.5in} ln {margin-top:0.1in; margin-bottom:0.1in} "] --> </style> </head> <body> <h1>CSS Test</h1> </body> </html> Its a little messy but not too bad. If you want to insert into such a quoted string you have to use "][ inserted-scheme-expr-here ][" e.g. (servlet (X Y Z) {<html> <head> <title>CSS test</title> <style><!-- [" body {background:rgb(255,255,240); padding:"][ X ]["in} ln {margin-top:"][Y]["in; margin-bottom:"][(+ Z 0.1)]["in} "] --> </style> </head> <body> <h1>CSS Test</h1> </body> </html> This is certainly simpler than my early proposal with curly-curly-delim ... {{" ......"[...]"......"}} On May 23, 2004, at 5:11 PM, Ken Anderson wrote: > Here are two proposals: > > P1: Use as the quasistring delimiter {{ also inside a quasistring > expression {{ starts an escape to Scheme. I think i found this > approach in another web application and sent email to the group. Interesting approach and quite easy, but it doesn't seem to buy as much as the other proposals. > > The advantage is > - you can keep the current syntax, if you only see { and use the new > one if you see { > - Only one character #\{ becomes special. > - I'm guessing that "{{" is uncommon. > > P2: Common Lisp has a very flexible reader controlled by a read-table. > (Once i sat down to work on a Lisp Machine that was reading in ALGOL > syntax, boy was i suprised.) One way to extend CL was to add > reader-macros that had the form > #name where name was the name of a macro, typical one character, like > #?. These are extensions of #t #f #(). Providing this facility would > let anyone add a way of swithching syntax. For example, Rahul could > have solved his javascript problem by using #js{....}, say. This is an interesting idea. It seems quite powerful and relatively simple to understand but it has a delimiter problem unless we say,e.g. the first non-alphanumeric character after the # is the string delimiter, e.g. #js@ ...... @ or #js#.......# or #js$.......$ with the exception that parenthesis type operators match as expected #js(.....) #js[.....] #js{...} #js<.....> How does one define a reader and install it in Common Lisp? Is it just a function from strings to sexpr? How does it interact with error reporting (.e.g error in proc F in file g.scm on line 5 char 16, which JScheme doesn't do anyway...) It would be nice to have a modular lexical syntax mechanism so that one could write lexical macros as well as procedural macros... Currently we use # in several instances .. #'a' #'\uFFE6' unicode characters #(1 2 3 4) vectors #t #f boolean (ahh this breaks the pattern....) Maybe we need prefix to indicate it is a reader. Another problem with this notation, is that it would be nice to use # notation for typed arrays, e.g. #int(1 2 3 4 5) #double(1 2 3 4 5) #int[](#int(1 2) #int(3 4)) #String("abcd" "efgh") But we can always use (list->array TYPE LIST) to get the same effect (or ([] TYPE LIST)) > > This proposal is just to add #... extension capability. > > P3: I've been interested in rewriting the JScheme (read) in Scheme as > a finite state machine, and compile it into Java. This should be > relatively easy because we only have a relatively small number of > types and operations. This could either implement P2 or the full > read-table approach. This would have the advantage of speeding up the reader and providing a model for writing read-macros > > I guess i've vote for P1 as the easiest thing to do at this point. Lets keep thinking about it..... ---Tim--- > k > > > At 07:12 PM 5/21/2004 -0400, Timothy John Hickey wrote: >> That shouldn't be too hard. What delimiters would you suggest? >> >> >> What would you think about some kind of general string delimiter say >> like this >> >> {{+ Here is "some" {javascript} or {CSS} or arrays A[x] or ... >> and here is a Scheme escape +[(Date.)]+ >> hmmmm? +}} >> >> where the character following the >> {{ >> indicates the stop character for the string, in this case >> + >> and >> +[ ]+ >> would delimit the quasi-string escapes..... >> >> So you could equivalently use a period >> >> {{. Here is "some" {javascript} or {CSS} or arrays A[x] or ... >> and here is a Scheme escape .[(Date.)]. >> hmmmm? .}} >> >> or a double quote >> >> {{" Here is "some" {javascript} or {CSS} or arrays A[x] or ... >> and here is a Scheme escape "[(Date.)]" >> hmmmm? "}} >> >> and you could switch midway with each [...] providing an opportunity >> to switch delimiters. For example, here we switch from " to * to @ >> >> >> {{" Here is "some" {javascript} or {CSS} or arrays A[x] or ... >> and here is a Scheme escape "[(Date.)]* >> hmmmm? here is a square bracket "[" see? >> maybe just switch for fun *[]@ hmmmm.. @}} >> >> What do you think? Would this have helped make the code cleaner >> and the developers happy? >> >> What do other JSchemer's think of this notation? >> Any other ideas for handling the string delimiter problem? > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle > 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user > |
From: Rahul <Rah...@Su...> - 2004-05-24 14:42:27
|
Hi, > There is a relatively simple approach to this problem that doesn't > require backquoting... > The idea is just to escape into a regular quoted string with [" ..... "] > e.g. That solution would help very much though we would still need to escape the inner quotes. ( quotes are Present often in js but not as common as the { } and [ ] ,so i guess escaping them wont be that messy) ~Rahul -- /*With eyes that speak of the Stars, and magick my very soul, A Dragon I am Eternal.*/ |
From: Timothy J. H. <ti...@cs...> - 2004-05-24 15:21:32
|
On May 24, 2004, at 10:40 AM, Rahul wrote: > Hi, > >> There is a relatively simple approach to this problem that doesn't >> require backquoting... >> The idea is just to escape into a regular quoted string with [" ..... >> "] >> e.g. > > That solution would help very much though we would still need to > escape the inner quotes. You might be able to use single quotes in place of double quotes.... Yet another possibility would be to use #{ }# to denote quoted strings where } can appear with in the quoted string, but you would have to backslash any appearance of }# This is lexically similar to the mzscheme style multi-line comments #| ...... |# The downside: it adds two additional characters to a string and it introduces # as a terminating symbol for the first time, and it still requires one to backslash square brackets, which arise in javascript code... The upside: it is very simple to implement and is backwards compatible. Maybe use #[ ]# as escapes into Scheme for these #-quasi-strings... For example, we could include the following chunk of Javascript from google as follows: (define (js-string zzz) #{ <script> <!-- function qs(el) {if (window.RegExp && window.encodeURIComponent) {var qe=encodeURIComponent(document.f.q.value); if (el.href.indexOf("q=")!=-1) {el.href=el.href.replace(new RegExp("q=[^&$]*"),"q="+qe);} else {el.href+="&q="+qe;}}return 1;} // --> #[zzz]# </script> }# ) where the curly braces, square brackets, and various quotes don't need to be quoted and where I've inserted a gratutitous argument using the #[...]# notation. I'm starting to like this approach. It is easy to understand, easy to implement, and handles 95% of the interesting cases (CSS quoting, javascript quoting, probably also SQL and Jython quoting). ---Tim--- > ( quotes are Present often in js but not as common as the { } and [ ] > ,so i guess escaping them wont be that messy) > > ~Rahul > -- > /*With eyes that speak of the Stars, > and magick my very soul, > A Dragon I am Eternal.*/ > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle > 10g.Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |
From: Ken A. <kan...@bb...> - 2004-05-24 17:35:00
|
Chapter 17 of Paul Graham's On Lisp, http://paulgraham.com/onlisptext.html talks about read-macros and dispatch-macro-characters which is what the #{ would be called. Here's the chapter from the hyperspec: http://www.lisp.org/HyperSpec/Body/sec_the_reader_dictionary.html |
From: Ken A. <kan...@bb...> - 2004-05-24 17:21:22
|
What about #{ ... #} and #[ ... #] instead? I liked {{ because it only uses up one character, but using # would lets us support reader macros. I'll need to remember more of how we did them in CL. |
From: Timothy J. H. <ti...@cs...> - 2004-05-24 17:33:41
|
On May 24, 2004, at 1:21 PM, Ken Anderson wrote: > What about #{ ... #} and #[ ... #] instead? Hmmmm. So a typical use would look like the following.... (define (js-string zzz) #{ <script> <!-- function qs(el) {if (window.RegExp && window.encodeURIComponent) {var qe=encodeURIComponent(document.f.q.value); if (el.href.indexOf("q=")!=-1) {el.href=el.href.replace(new RegExp("q=[^&$]*"),"q="+qe);} else {el.href+="&q="+qe;}}return 1;} // --> #[zzz #] </script> #} ) The advantage is that the tokens indicating the beginning/end of string status always start with the # character. Yes, I think that is nicer. We then think of #{ #} #[ #] as tokens although #[ and #} denote the ends of strings, while #{ and #] denote the beginnings of strings in different contexts... ---Tim--- > > I liked {{ because it only uses up one character, but using # would > lets us support reader macros. I'll need to remember more of how we > did them in CL. > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle > 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |
From: Rahul <Rah...@Su...> - 2004-05-22 12:53:26
|
> How does management feel about Scheme now? > For example, would they be happy to have a link to their site from the > JScheme website > talking about a success story? .... or would it be counter productive to > advertise the fact? > Maybe they would prefer not to advertise the underlying implementation > stories.... I had talked with them on that issue, They were not very welcome to that idea [we had an xslt based interface with xalan providing the rendering. They had used that as one of the marketing points [compliance with stds and total xml based and stuff] they tolerated me because they got it mostly free. But I hope they will be more open to it when other devs use it and the ease of use comes to their attention. -- I am also trying to use jscheme here in my current firm. > What would you think about some kind of general string delimiter say > like this I think i prefer the way you have described. (but not sure switching midway would be useful.) It would also be nice if multiline comments were possible. ~Rahul -- blufox.batcave.net /*With eyes that speak of the Stars, and magick my very soul, A Dragon I am Eternal.*/ |