Re: Efficiency of generic programming Andre van Tonder 07 Oct 2005 17:36 UTC

 > From: Andre van Tonder <xxxxxx@now.het.brown.edu>

 > - Functional update encourages functional style programming.

 Simple example:  A functional style account management system

   ;; close : (forall A: A<=Account). A -> A

   (define (close acc)
     (update-account acc (balance 0)))

 Close will work on subtypes of the Account type, and returns a /new/
 instance of the subtype with the balance field updated.  UPDATE-ACCOUNT
 is a macro.

 This is a very natural thing to do in a functional language.
 With the current SRFI, I can easily express the UPDATE-ACCOUNT macro
 in terms of the given primitives, but because of the o(N) record length
 operation, the copying of subtype fields will be less efficient than
 it could be.  So at least for this kind of thing, the SRFI seems to have
 a bit of a bias against the functional way of solving the problem.

 Cheers
 Andre