[racket] sound + universe report: success.

From: John Clements (clements at brinckerhoff.org)
Date: Thu Oct 20 14:27:32 EDT 2011

On Oct 20, 2011, at 3:53 AM, Stephen Bloch wrote:

> 
> On Oct 20, 2011, at 1:20 AM, John Clements wrote:
> 
>> I'm pleased to report that the sound library works pretty transparently with the universe teachpack.
>> ...
>> (define (accelerate b)
>> (cond [(and (<= (ball-posn b) 6)
>>             (<= (ball-vel b) 0)) 
>>        (begin (play pop)
>>               (make-ball 6 (- (ball-vel b))))]
>>       [else
>>        (make-ball (+ (ball-posn b) (ball-vel b))
>>                   (- (ball-vel b) 1))]))
>> ...
>> The larger question could potentially be whether the sound-playing should be less imperative. If you wanted, you could add a "to-play" along with "to-draw", and just make the sound-playing part of the world state. This would avoid the "begin".
> 
> 
> "to-play" MIGHT be a good way to do things, but in many cases (including the above "accelerate" example) it'll be more natural to specify a sound as you determine the new world, rather than as a separate function of the state of the world.  It's analogous to the difference between "stop-when" and "stop-with".  One could provide this ability very simply:
> 
> (define (play-with sound world)
>      (begin (play sound) world))

Yes, but how do you write test cases for this?

John

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20111020/a3143752/attachment.p7s>

Posted on the users mailing list.