[plt-scheme] HtDP ex 11.2.4

From: Richard Cleis (rcleis at mac.com)
Date: Sat Feb 18 12:50:30 EST 2006

> This is equivalent. The key is that the template is isomorphic to the 
> data definition so that if you (or someone else) ever needs to go back 
> and modify things, it's easy to know what corresponds to what.

*blush* I was totally forgetting that point (regards to Carl, too).  It 
would have been obvious that "symbol?" and "cons?" were expected to be 
available if I had fully understood this concept.  Self-teaching has 
limitations, but I can't find any lectures offered after midnight.

> After all "modifying" things includes changing the data: deleting a 
> clause, adding a clause, adding a field to a struct in  certain 
> clause, deleting them, etc. My personal preference is to order the 
> clauses in the cond/case/match in the same way as I order the clauses 
> in the data def. I have come to nest conditionals almost always, 
> rather than flattening out the cond.

I was wondering about that, too.  These clause-issues surface often in 
my day to day programming, but I never learned to think in terms of 
data definitions first (which in turn guide the form of the function).  
  After all, C can point to anything at any time ;)

> If I want a performance advantage (because I know or Matthew has told 
> me how things work exactly), I may reorder the Data Def so that I can 
> re-order the clauses in the cond/case/record-case/matchh etc.
> Hope this makes sense. One day I intend to summarize the How to Design 
> books in an compact "adult" version with reasoning as above. For now 
> you need to infer this.
> -- Matthias

Posted on the users mailing list.