Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Stephen Bloch
On Jul 16, 2011, at 1:58 PM, Shriram Krishnamurthi wrote: > On Sat, Jul 16, 2011 at 11:16 AM, Stephen Bloch wrote: >> >> Here's another idea: provide a "sprite+picture" structure, and have all the >> operations take in and return it. > > This is unwieldy beyond measure in our syntax. Yes, th

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Mark Engelberg
On Sat, Jul 16, 2011 at 7:33 AM, Stephen Bloch wrote: > These functions would presumably maintain the invariant that each name > corresponds to at most one sprite in a world.  Letting the kids manipulate > the list of sprites directly does NOT maintain that invariant, so I think I > have to do

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Shriram Krishnamurthi
On Sat, Jul 16, 2011 at 11:16 AM, Stephen Bloch wrote: > > Here's another idea: provide a "sprite+picture" structure, and have all the > operations take in and return it. This is unwieldy beyond measure in our syntax. Shriram _ For list-related

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Ivanyi Peter
Matthias Felleisen írta: > > And that leaves only one option: start with mathematical-style programming > because we know that this is mathematics and there is no transfer needed. It > is the *same* skill. Just my 2 cents. :-)) I fully agree with this. We teach "web programmers". They learn

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Stephen Bloch
On Jul 16, 2011, at 10:33 AM, I wrote: > some version of [each sprite having a name] may be the least-bad idea so far, > including mine :-) Here's another idea: provide a "sprite+picture" structure, and have all the operations take in and return it. One could use it directly as a world in bi

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Matthias Felleisen
On Jul 16, 2011, at 10:55 AM, Stephen Bloch wrote: > I have a hard time believing that EVERY CS educator who evangelizes for > something other than PBD "has no scruples". I made a typically Matthias-strong statement and I need to explain what I mean. 1. We want to teach every child how to

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Stephen Bloch
On Jul 16, 2011, at 10:34 AM, Matthias Felleisen wrote: > Since these people have no scruples -- don't even understand that they dont > have any -- go for the imperative version. I have a hard time believing that EVERY CS educator who evangelizes for something other than PBD "has no scruples".

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Matthias Felleisen
On Jul 16, 2011, at 10:16 AM, Stephen Bloch wrote: > I'm looking at our competition in the marketplace of ideas, and I want to > beat (or at least match) them at their own game. > > Who's with me? Since these people have no scruples -- don't even understand that they dont have any -- go for t

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Stephen Bloch
Mark Engelberg wrote: > I see you're already representing the World as a picture and a list of > sprites, so just let the kids manipulate that directly. > > Since you want to support multiple sprites, what if each sprite in the > sprite list had a name, so the contract is: > move: String (sprite-

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Stephen Bloch
On Jul 16, 2011, at 12:46 AM, Nadeem Abdul Hamid wrote: > Ah, right. How about you keep the picture separate, and functions like > 'move', 'rotate', etc. add to a list in the sprite structure; when the sprite > structure is passed to the draw handler, the draw handler updates the picture > bas

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Stephen Bloch
Carl Eastlund wrote: > Why is affecting the sprite "functional" and affecting the picture > "imperative"? Any part of a program can be mutated imperatively, and > likewise any part of a program can be passed around functionally. If > you need to modify the picture, why not pass around the pictur

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-16 Thread Stephen Bloch
On Jul 15, 2011, at 3:12 PM, Matthias Felleisen wrote: > I don't understand your solution. But if students cannot test their event > handling functions in a functional style, then the answer to the last > question is YES, you're pregnant. Based on my toy examples so far, they can test their e

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-15 Thread Nadeem Abdul Hamid
On Sat, Jul 16, 2011 at 12:34 AM, Mark Engelberg wrote: > > Because the image is not only dependent upon the current location of > the sprite, but also the entire history of the sprite's movements when > its pen was down. So you either have to store a very long list of > line segments in the worl

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-15 Thread Mark Engelberg
On Fri, Jul 15, 2011 at 11:56 AM, Stephen Bloch wrote: > Last Monday I attended Dan Garcia's workshop on BYOB.  He kept pointing out > (presumably for the benefit of Emmanuel and me) that it really is a > functional language.  And yes, it has "map", "filter", "foldl", and > "lambda"... but most

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-15 Thread Mark Engelberg
On Fri, Jul 15, 2011 at 12:24 PM, Nadeem Abdul Hamid wrote: >  Why don't you just have the picture generated based on the state of the > sprite each tick of the animation, just as in HtDP "world"? Functions like > move, rotate, etc. produce a modified sprite, and when that sprite gets > passed to

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-15 Thread Nadeem Abdul Hamid
On Fri, Jul 15, 2011 at 2:56 PM, Stephen Bloch wrote: > The problem is that some sprite actions (most obviously, "move" when you're > in pen-down mode) affect not only the sprite itself but the world's picture. > So far the least-bad solution I've come up with is to hide a mutation of > that pic

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-15 Thread Carl Eastlund
On Fri, Jul 15, 2011 at 2:56 PM, Stephen Bloch wrote: > Last Monday I attended Dan Garcia's workshop on BYOB.  He kept pointing out > (presumably for the benefit of Emmanuel > and me) that it really is a functional language.  And yes, it has "map", > "filter", "foldl", and "lambda"... but most o

Re: [racket] Advice: simulating stateful API in functional setting

2011-07-15 Thread Matthias Felleisen
On Jul 15, 2011, at 2:56 PM, Stephen Bloch wrote: > I've experimented with a couple of ways to do that. One way is to define (in > my code, not visible to student code) a box named "world-pic", which is > set-box!ed in "move" and "run-byob-world". Another is to use just a plain > variable an

[racket] Advice: simulating stateful API in functional setting

2011-07-15 Thread Stephen Bloch
Last Monday I attended Dan Garcia's workshop on BYOB. He kept pointing out (presumably for the benefit of Emmanuel and me) that it really is a functional language. And yes, it has "map", "filter", "foldl", and "lambda"... but most of the examples and assignments one normally does in BYOB use v