[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Specialized input parsing for code/REPL in DrScheme?



Robert-

Thanks for the information -- it's a start! 

I also appreciate the offer to expose that part of the base system if
sensible/neccessary. I see classes are starting again at Rice real soon, 
  http://www.ruf.rice.edu/~reg/calendars/acadcalf00.html
so I'm sure you all will have your hands full with other things shortly
(if not now in preparation).

I hadn't looked through the tools stuff, so thanks for the pointer
By the way, for the "m3" documentation, this link works:
  * http://www.cs.rice.edu/CS/PLT/packages/102/doc/m3/index.htm
But this link does not:
 * http://www.cs.rice.edu/CS/PLT/packages/102/DocBundles/m3-doc.plt.

Right now, rather than rush into this, I'm still trying to see just how
much work it would be in DrScheme. I'm more used to Smalltalk where
typically (Squeak, VisualWorks) the parser, compiler, formatter, etc.
are pretty much always written in Smalltalk and are usually easily
accessible in source and changeable (including by subclassing). It seems
that in the Lisp world (not necessarily DrScheme - I need to understand
it more) these things are more often written in C and hidden in the base
code. Even when you get hooks, there is still a lot of writing to do to
rewrite the C in Lisp or Scheme (or find such already written).

However, it might be fun to build a reader as you say, and then if it
works, worry about hooking it up later. Since I'm still learning Scheme
(and it's strengths and weaknesses), even a failure will be a success
(as
far as learning). 

By the way, I found one of the most interesting replies (appropriate to
the future of programmming environments like DrScheme) to be one by
Chris Page.
He points toward how programming can rise above languages and textual
representations. He mentions the book "Human Factors and Typography for
More Readable Programs" by Ronald M. Baecker & Aaron Marcus. Chris's
full comment is available at:
http://x56.deja.com/getdoc.xp?AN=656713307&CONTEXT=965918514.123535370&hitnum=18

-Paul Fernhout
Kurtz-Fernhout Software 
=========================================================
Developers of custom software and educational simulations
Creators of the Garden with Insight(TM) garden simulator
http://www.kurtz-fernhout.com

Robert Bruce Findler wrote:
> 
> The best way to implement something like this is to write your own
> reader (ie a procedure that accepts a port and returns an sexp).
> Then, you can use that reader instead of the one supplied with
> DrScheme and just hook into the usual parsers.
> 
> The tricky part will be getting DrScheme itself to use your reader.
> The environment is designed to be "open" (via the tools mechanism),
> but so far the exposed procedures have been added on an as needed
> basis. I suspect that this kind of change is either difficult or
> impossible (I guess that it is merely the former :). Check out the
> tools manual for more information. Don't hesitate to contact me if
> you get stuck or need some more infrastructure exposed.
> 
> From the forewarned is forarmed department, there are two readers in
> DrScheme currently: one tracks source location information and the
> other doesn't. So, your reader will need to do both if it is to
> actually make it into DrScheme someday.
> 
> Good Luck! Hope that helps!
> 
> Robby
> 
> >I'm interested in being able to flip between alternate textual
> >representations in DrScheme. I'm trying to determine how hard this would
> >be to implement in DrScheme.
> >
> >Specifically, I'd like to flip back and forth in the DrScheme editor
> >between conventional Scheme syntax and a syntax where indentation is
> >significant (like in Python or Occam) and thus parentheses at the edges
> >of lines can be removed as redundant.
> >
> >For example:
> >
> >(define (square x)
> >   (* x x))
> >
> >would become:
> >
> >define (square x)
> >   * x x
> >
> >and vice versa. I posted a thread on this to comp.lang.lisp if anyone
> >wants the specifics.
> >http://x66.deja.com/viewthread.xp?AN=656209628.4&search=thread&svccla
> >ss=dncurrent&ST=PS&CONTEXT=965870095.884932614&HIT_CONTEXT=965870095.8
> >84932614&HIT_NUM=1&recnum=%3c3990E003.6EE78131@kurtz-fernhout.com%3e%2
> >34/4&group=comp.lang.lisp&frpage=viewthread.xp&back=clarinet
> >
> >So my question is, in DrScheme, how should I best go about doing this
> >(in terms of interfacing with DrScheme, not specifically the parsing)?
> >Is there a way to do this completely in Scheme (I hope) or will I have
> >to recompile DrScheme and make changes to the C code?
> >
> >Note this is something very different from defining a macro as far as I
> >can tell -- since I am fundamentally changing the interpretation of the
> >text before it is made into nested lists.
> >
> >I see there are some hooks and code for printing in DrScheme,
> >specifically
> >   Converted Printing: pconver.ss
> >   Pretty Printing: pretty.ss
> >so I have something to start with.
> >
> >The part that looks harder is transparently taking the code entered into
> >DrScheme, perhaps checking the first line or so for a flag
> >(indent-mode-on?) and then using an alternate parser (hopefully
> >writeable in Scheme). I'm not sure where to begin.
> >
> >Can anyone rough out the big picture of what I need to do to accomplish
> >this in DrScheme?  The easier and more in Scheme the approach, the
> >better. I looked at the docs, but didn't see anything obvious on hooking
> >the REPL handler. Is it in there somewhere? I'd also like to hook saving
> >the file, so I could transparently save the alternative syntax as
> >standard Scheme syntax.
> >
> >Naturally people on comp.lang.lisp suggest I do this as emacs Lisp
> >macros, but a DrScheme implementation would probably be more useful for
> >me (and hopefully might interest people on this list as well). Of
> >course, what they mostly suggest is that this is just a bad idea, but
> >I'm curious enough to at least want to see how difficult it would be to
> >implement it.
> >
> >I guess this is the "second system" effect Fred Brooks warns about.
> >   http://www.best.com/~rgm/notebook/second-system.html
> >One tiny success with a simple plug-in (still in need of error handling
> >no less!) and I think I can rewrite Scheme parsing rules... :-)
> >
> >Note: Educational motivations for this (if any are needed) are:
> >* an easy way to switch between syntaxes might allow students to
> >experiment with their own mini-languages and parsers more easily using
> >the DrScheme system (by hooking the REPL with their own handler)
> >* this alternative syntax might be easier to understand or perhaps learn
> >for some Scheme novices -- especially those coming from Python (I don't
> >say this is necessarily true, but I can hope).
> >
> >-Paul Fernhout
> >Kurtz-Fernhout Software
> >=========================================================
> >Developers of custom software and educational simulations
> >Creators of the Garden with Insight(TM) garden simulator
> >http://www.kurtz-fernhout.com