[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Efficiency of generic programming

This page is part of the web mail archives of SRFI 76 from before July 7th, 2015. The new archives for SRFI 76 contain all messages, not just those from before July 7th, 2015.

 > From: Andre van Tonder <andre@xxxxxxxxxxxxxxxxx>
 > - 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.