I&#39;m playing around with the universe teachpack, and am curious whether anyone has thoughts about how to make the coding of worlds reasonably easy and intuitive for kids.  I&#39;ve been playing around with structuring worlds as structs.  The issue then becomes how to make modifications to a world in a clean way.  What seems most natural to me is to use some kind of functional update to change individual fields.  So, for a simple world consisting of a position and velocity:<br>
<br><span style="font-family: courier new,monospace;">;; world type</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define-struct world (pos vel))</span><br><br>But then, I want a lightweight way of changing just the position or just the velocity, so I write operations like this:<br>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define (set-world-pos world x)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (make-world x (world-vel world)))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">(define (set-world-vel world x)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (make-world (world-pos world) x))</span><br>
<br>This is obviously somewhat brittle, since the code above will break if I add a new field to the world struct.<br><br>So, there are really two questions.  The first is, is there a better way of doing this in the student-oriented languages.  And second, is this a good way of encouraging kids to write this kind of code?  Or is the right thing to have them recreate the entire struct from scratch every time they want to modify a field.<br>
<br>y<br>