Guile Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
measured use of multimethods, was setf.scm
- To: email@example.com
- Subject: measured use of multimethods, was setf.scm
- From: Ken Anderson <firstname.lastname@example.org>
- Date: Fri, 18 Dec 1998 09:06:41 -0500
- Cc: amp-Developers@bbn.com, MThome@bbn.com, "Geoffrey S. Knauth" <email@example.com>, firstname.lastname@example.org, email@example.com, JZinky@bbn.com, firstname.lastname@example.org, "Harper, Michael L." <Michael.Harper@alcoa.com>
- Content-Type: text/plain; charset="us-ascii"
- Message-Id: <email@example.com>
- Sender: firstname.lastname@example.org
There has been a lively discussion on issues like setf, multimethods
(methods that dispatch on multiple arguments) and object oriented dispatch
This prompted me to try to dig up some real statistics from one of our
applications, AMP. We have several others, though the statistics may
overlap because of software reuse. I believe this kind of natural science
of software can be valuable. To see if multiple dispatch is useful, it
helps to study it in the wild, such as wild Common Lisp and Cecile
programs. AMP has been going on in various forms since September 1990.
AMP is written in CLOS which provides for multiple argument dispatch and
developers are free to use this feature as they see fit. It contains
250,000 lines of code from 30+ developers, most who have never met. Major
components include CLIM and CL-HTTP and others in to 50K line of code
range. So, it is likely to represent a wide range of Common Lisp
250,000 Lines of code
10,121 generic functions (and many other normal functions ...)
1.9 methods per generic function
(the median is 1, the max is 321 for print-object)
9,563 methods with more than one argument (50%)
1,981 methods using multiple dispatch
20.7 % of methods with 2+ arguments that are multimethods.
Histogram of number of arguments, #arguments, per generic function:
20.7% of the methods that can use multiple dispatch, do.
11% of the generic functions use multiple dispatch.
Since many two argument generics are automatically generated setf methods,
the actual number of hand written multimethods could be higher.
This suggests that multimethods capture a common (20% or more) programming
pattern that may be worth implementing directly in your language. In
Common Lisp, i simply use this capability when i need to. Since it does
not exist in Java, i simply miss it.
Guile Home |
Main Index |