Fred G. Martin | 29 Mar 18:20
Favicon

evaluating buffer w/o re-initializing environment?

Dear PLT-Scheme'rs,

One of the things I really miss in Dr. Scheme is the ability to add
new definition bindings without losing the state of the global
environment.  When you evaluate a buffer with F5 or Run, the world is
reset and then the buffer definitions are evaluated and put back.

Am I missing something easy, or is this a deep design decision?  I
wish I could introduce my students to the Lisp programming methodology
of iteratively building up the objects in one's world and the
procedures for interacting with them.

Fred
Jos Koot | 30 Mar 01:59
Favicon

Re: evaluating buffer w/o re-initializing environment?

Hi,
I did my first programs on punched Hollerith cards for batch processing. 
This makes you think twice before designing and writing down a program. No 
interactive terminals in those days (except the operator's main frame 
control board, which I used once in order to interact (and the whole main 
frame went down within a few minutes. As the main frame went down more 
often, it apparently was not noticed, for I never received a reprimande. A 
short look into the so called 'dayfile' would soon have revealed my sinn) 
Easy access to tools that can help develop ideas about how to construct 
certain parts of your program are nice of course, but the most important 
part of programming has to be done in the head, probably with the help of 
paper and a pencil. Having too easy tools to try out little pieces of code 
interactively may lead to trial and error programming, horrible. In this 
respect HtDP does a good job, I think. It guides the student to think about 
what has to be done before actually entering the final code. And this code 
is to be entered in the definitions window, of course. Therefore I don't 
mind Run to reset DrScheme, on the contrary, I like it, for it makes me sure 
that the erroneuous past is completely forgotten (and all previously running 
user threads being killed!) Mho, Jos

----- Original Message ----- 
From: "Fred G. Martin" <fredm@...>
To: "pltscheme" <plt-scheme@...>
Sent: Sunday, March 29, 2009 6:20 PM
Subject: [plt-scheme] evaluating buffer w/o re-initializing environment?


> Dear PLT-Scheme'rs, > > One of the things I really miss in Dr. Scheme is the ability to add > new definition bindings without losing the state of the global > environment. When you evaluate a buffer with F5 or Run, the world is > reset and then the buffer definitions are evaluated and put back. > > Am I missing something easy, or is this a deep design decision? I > wish I could introduce my students to the Lisp programming methodology > of iteratively building up the objects in one's world and the > procedures for interacting with them. > > Fred > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme >
Grant Rettke | 29 Mar 22:34
Picon
Favicon
Gravatar

Re: evaluating buffer w/o re-initializing environment?


On Sun, Mar 29, 2009 at 11:20 AM, Fred G. Martin <fredm@...> wrote: > One of the things I really miss in Dr. Scheme is the ability to add > new definition bindings without losing the state of the global > environment.  When you evaluate a buffer with F5 or Run, the world is > reset and then the buffer definitions are evaluated and put back.
I am guessing that most people avoid this by doing the exploratory part of the programming inside of the REPL and when they are happy with new functions they do a: M:S:right-arrow C:c C:F6 C:v
Grant Rettke | 29 Mar 18:50
Picon
Favicon
Gravatar

Re: evaluating buffer w/o re-initializing environment?

http://list.cs.brown.edu/pipermail/plt-scheme/2007-June/018806.html

On Sun, Mar 29, 2009 at 11:20 AM, Fred G. Martin <fredm@...> wrote:

> Dear PLT-Scheme'rs, > > One of the things I really miss in Dr. Scheme is the ability to add > new definition bindings without losing the state of the global > environment.  When you evaluate a buffer with F5 or Run, the world is > reset and then the buffer definitions are evaluated and put back. > > Am I missing something easy, or is this a deep design decision?  I > wish I could introduce my students to the Lisp programming methodology > of iteratively building up the objects in one's world and the > procedures for interacting with them. > > Fred > _________________________________________________ >  For list-related administrative tasks: >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme >
-- -- http://www.wisdomandwonder.com/
Geoffrey S. Knauth | 29 Mar 20:09
Gravatar

Re: evaluating buffer w/o re-initializing environment?

On Mar 29, 2009, at 12:50, Grant Rettke quoted Matthias from June 2007:

and in there I saw:

"Escape-control-x is for very small programs and macho, heroic young programmers who have time to waste (including on IRC channels). Real programmers use transparent REPLs."

I'm fine with Matthias's explanation above and at [1].  Sometimes though, I wish I could hold on to, say, a database connection.

Regarding the above quotation, I've used Emacs for 25 years, but I'm unsure what ESC C-x means.  My current Emacs (v22/v23) doesn't understand it.  Matthias, I'm guessing you meant C-x C-e, eval-last-sexp.

To Fred:  In Emacs scheme-mode with mzscheme underneath, I use the behavior you asked about most unheroically, e.g.,

; hypothetical checking account
(- 1000.00 ; bank balance at Sun Mar 29 13:25:48 EDT 2009
    400.00 ; oil company #101
    100.00 ; phone company #102
    100.00 ; electric company #103
    125.00 ; cable company #104
    150.00 ; kids' school lunches #105
     50.00 ; charity contribution #106
     74.70 ; little/seasoned/reasoned schemers (amazon) #107
    )
;=> 0.30 ; I'm happy! [2]
; ok, truth be told FPU said it was 0.29999999999999716

Geoff


[2] "Annual income twenty pounds, annual expenditure nineteen six, result happiness. Annual income twenty pounds, annual expenditure twenty pound ought and six, result misery." (Charles Dickens, David Copperfield)
Will M Farr | 30 Mar 16:26
Picon
Favicon

Re: evaluating buffer w/o re-initializing environment?


On Mar 29, 2009, at 2:09 PM, Geoffrey S. Knauth wrote:


> Regarding the above quotation, I've used Emacs for 25 years, but I'm > unsure what ESC C-x means.
Otherwise known as M-C-x, or "eval phrase" or "eval enclosing S-exp" or something like that. Put your cursor in the middle of an S-exp, and try it! Enjoy, Will
Dave Herman | 29 Mar 20:54
Gravatar

Re: evaluating buffer w/o re-initializing environment?


> I'm fine with Matthias's explanation above and at [1]. Sometimes > though, I wish I could hold on to, say, a database connection.
This sounds appealing, but -- I'm just conjecturing here -- it might turn out to be more trouble than it's worth. For example, if a database connection is represented as an instance of a struct, then re-running the program will generate a new, incompatible struct type. So even if you have persistent state stored in "cookies" somewhere, you won't actually be able to *use* your database connection. Even if you use some kind of more transparent data structure, the data might be tied to some stateful code somewhere, possibly buried deep in some transitively required library, and the new instance of the program that has generated fresh state is probably not expecting to interact with leftover data from a previous instance of the program. I suspect this is the kind of stuff that Matthias is talking about as causing extra unnecessary complexity that distracts even genius Lisp hackers. Dave
Geoffrey S. Knauth | 30 Mar 01:00
Gravatar

Re: evaluating buffer w/o re-initializing environment?


On Mar 29, 2009, at 14:54, Dave Herman wrote: > I suspect this [state supporting the example database connection] is > the kind of stuff that Matthias is talking about as causing extra > unnecessary complexity that distracts even genius Lisp hackers.
I'll go along with that. As it is, in DrScheme I press Cmd-T to rerun the code in my definitions window and a new database connection is made, but that hasn't caused me any pain.
Matthias Felleisen | 30 Mar 01:25

Re: evaluating buffer w/o re-initializing environment?


Dave has explained my reservations correctly, and as you say, it  
isn't too bad to re-open a db during development.

Having said that:

  + I miss send-sexpr and send-region on rare occasions
  + If someone wrote a tool that could be enabled properly
     and indicated with status that it's around, I might use it
  + I do think that a reverse tool -- develop in REPL, turn into a
    program and tests -- could be even better

But as you may know, DrScheme allows you to specify the "script"  
arguments in the language specs. This helps me    develop scripts and  
refer to command line arguments during testing. In a similar vein, it  
should be feasible to evolve drscheme so that it becomes a  
development environment for your favorite context (trying to avoid  
the word 'environment' here) and to tune it in similar manners for  
those contexts. Indeed, all this should be meta-data so that you can  
resume developing for the same context at some later point. And it  
should all be easy and transparent (which is what the argv context is  
missing at this moment).

One day DrScheme will be there. -- Matthias

  

Matthias Felleisen | 29 Mar 18:45

Re: evaluating buffer w/o re-initializing environment?


Dear Fred,

I am a product of the Emacs world that you are describing below,
and my advisor Dan Friedman was called the "Lispman" on his door
sign at Indiana.

When I first discovered the idea of sending individual expressions
and definitions from a buffer to a repl, it was a near-religious
revelation to me. I wanted everyone to know this trick and use it.
When I started teaching the freshman course at Rice, I told our
chairman so and he asked "why". I was shocked, awed, and I failed
to explain to him how it mattered. He was a mathematician and I
wrote it off. They don't know.

Then I started watching my sophomores and juniors at Rice in lab.
Now that was a true disappointment. Few if any used this trick and
when they did, they more often tripped up and got the repl into a
state where they didn't know what was going on.

In the mid 90s, I wrote some more Little books with Dan, and boy,
time and again, I watched him stumble across the state of the repl.
I even watched him re-start the repl and load the whole buffer more
often than not.

Why? In the presence of macros and higher-order functions and
other beasts, it is difficult for masters of the universe with 30
years of experience to keep track of things. What do you think
students with 10 or 20 days worth of experience will do? Is it
really such a deep principle of computing to create the objects
incrementally in the repl as opposed to thinking systematically
through the design of a program?

I decided not and asked Robby to make DrScheme's repl transparent.
That is, it re-starts the repl and re-loads the buffer every time.
I consider this behavior a suitable compromise: have a repl but
don't confuse yourself with send-defs and send-exprs. This is
especially true in an age when sending an entire buffer takes as
much time as sending an individual expression or definition.
Soon we'll get "compilation behind your back" so that only the
current buffer is re-interpreted. It'll start things even faster.

Even though I had used the incremental mode for more than a decade
when I switched from Emacs to DrScheme in 1998, I have hardly ever
looked back. I miss a few other things but the incremental repl
is one of those rituals old Lispers acquired and never questioned
... but it isn't fundamental and critical to anything

-- Matthias

On Mar 29, 2009, at 12:20 PM, Fred G. Martin wrote:


> Dear PLT-Scheme'rs, > > One of the things I really miss in Dr. Scheme is the ability to add > new definition bindings without losing the state of the global > environment. When you evaluate a buffer with F5 or Run, the world is > reset and then the buffer definitions are evaluated and put back. > > Am I missing something easy, or is this a deep design decision? I > wish I could introduce my students to the Lisp programming methodology > of iteratively building up the objects in one's world and the > procedures for interacting with them. > > Fred > _________________________________________________ > For list-related administrative tasks: > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
Neil Van Dyke | 29 Mar 20:37
Picon
Favicon

Re: evaluating buffer w/o re-initializing environment?

FWIW, I suspect that DrScheme would find more converts from Emacs if 
there were power-user features like send-last-sexp-to-repl and 
send-selection-to-repl.  Even if they don't work very well.

These rapid/exploratory features could be disabled for the student 
languages.  Otherwise you'll have hotshot students showing other 
students the features and subverting the pedagogic intent.

I'm not arguing too strongly for making DrScheme more friendly to power 
users.  If the Scheme consulting revenue permits, I have a plan to 
rewrite all the Emacs Scheme support from scratch, to make it much 
closer to DrScheme, while supporting more rapid/exploratory 
development.  I'm willing to add some kind of automatic HTDP student 
detection and lockout behavior. :)

--

-- 
http://www.neilvandyke.org/

Anthony Cowley | 29 Mar 21:38

Re: evaluating buffer w/o re-initializing environment?


On Sun, Mar 29, 2009 at 2:37 PM, Neil Van Dyke <neil@...> wrote: > FWIW, I suspect that DrScheme would find more converts from Emacs if there > were power-user features like send-last-sexp-to-repl and > send-selection-to-repl.  Even if they don't work very well. > ... > I'm not arguing too strongly for making DrScheme more friendly to power > users.  If the Scheme consulting revenue permits, I have a plan to rewrite > all the Emacs Scheme support from scratch, to make it much closer to > DrScheme, while supporting more rapid/exploratory development.  I'm willing > to add some kind of automatic HTDP student detection and lockout behavior. > :)
Would it be possible to add some of this support to DrScheme in the form of a plug-in? Perhaps that would ease the minds of those who don't want to encourage that style of development without punishing those who feel punished. As a very minor data point, my significant Scheme/Lisp programming began in DrScheme, and as I explored Lisps in Emacs, I quite missed the ability to send sexps to a live REPL when going back to DrScheme. It's the reverse direction from what Matthias described, and the reverse psychological impact. By way of justification for the feature, it is often hard to figure out what to do with intermediate data when developing moderately computationally intensive processing components (as in many kinds of computer vision applications). When working with Matlab, one tends to stash partially processed data in the workspace while working on subsequent layers of processing. Of course, one does periodically have to clear the workspace, or at least certain elements of it, when the situation has become inconsistent, but, despite this admittedly dangerous shortcoming, it is a viable workflow. When working with Lisp and Emacs, the REPL can be a handy place to have live data hang out. Unfortunately, I haven't found a technique that I'm totally satisfied with in DrScheme. In particular, I'm referring to data that takes on the order of 10 seconds to a minute or so to compute. Any longer, and serializing to disk is probably advisable, and perhaps the correct advice here is to always write the data to disk, as an sexp, since reloading it is so straightforward, but I can't help but feel that more persistent REPLs have some advantage here. For another example, using environments such as Impromptu <http://impromptu.moso.com.au/manual.html> to fine tune visual displays is a truly fantastic experience. Anthony
Geoffrey S. Knauth | 30 Mar 01:10
Gravatar

Re: evaluating buffer w/o re-initializing environment?


On Mar 29, 2009, at 15:38, Anthony Cowley wrote: > For another example, using environments such as Impromptu > <http://impromptu.moso.com.au/manual.html> to fine tune visual > displays is a truly fantastic experience.
Thanks for mentioning Impromptu, I'd forgotten about it. Impromptu and Processing make an interesting comparison.
Robby Findler | 29 Mar 21:50
Favicon

Re: evaluating buffer w/o re-initializing environment?


On Sun, Mar 29, 2009 at 2:38 PM, Anthony Cowley <acowley@...> wrote: > On Sun, Mar 29, 2009 at 2:37 PM, Neil Van Dyke <neil@...> wrote: >> FWIW, I suspect that DrScheme would find more converts from Emacs if there >> were power-user features like send-last-sexp-to-repl and >> send-selection-to-repl.  Even if they don't work very well. >> ... >> I'm not arguing too strongly for making DrScheme more friendly to power >> users.  If the Scheme consulting revenue permits, I have a plan to rewrite >> all the Emacs Scheme support from scratch, to make it much closer to >> DrScheme, while supporting more rapid/exploratory development.  I'm willing >> to add some kind of automatic HTDP student detection and lockout behavior. >> :) > > > Would it be possible to add some of this support to DrScheme in the > form of a plug-in?
Yes, and you can even put the thing on planet. Robby

Gmane