			DATA-DIRECTED PROGRAMMING

1. 

  (define (standard-rainfall weather)  (cadr weather))
  (define (metric-rainfall weather)    (cm-to-in (caddr weather)))
  (define (engineer-rainfall weather)  (mm-to-in (cadddr weather)))
  (define (standard-windspeed weather) (caddr weather))
  (define (metric-windspeed weather)   (kph-to-mph (cadddr weather)))
  (define (engineer-windspeed weather) (mps-to-mph (cadr weather)))


2.
   (put 'S 'temp standard-temp)
   (put 'S 'precip standard-rainfall)
   (put 'S 'wind standard-windspeed)
   (put 'M 'temp metric-temp)
   (put 'M 'precip metric-rainfall)
   (put 'M 'wind metric-windspeed)
   (put 'E 'temp engineer-temp)
   (put 'E 'precip engineer-rainfall)
   (put 'E 'wind engineer-windspeed)

    OR (put 'S 'temp (lambda (W) (standard-temp W)))  ;; Same idea for all...

3.
   (define tag car)      ;; Abstractions!!

   (define (get-temperature weather)
     (get (tag weather) 'temp weather))

   (define (get-rainfall weather)
     (get (tag weather) 'precip weather))

   (define (get-windspeed weather)
     (get (tag weather) 'wind weather))

4. It's hard to say which is better, without knowing what is most desired.
   Either method allows for easy modifications in terms of adding new
   weather data.  However, if you were planning on taking your database
   with you when you did on-site locations in all kinds of other places,
   you'd be better off with the Boston system of data-directed
   programming.  Otherwise, you'd have to rewrite the entire message-
   passing system all over again for the new town.  (But this wasn't an
   issue the way the question was asked.)
