This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
There has been a lively discussion on issues like setf, multimethods (methods that dispatch on multiple arguments) and object oriented dispatch in general. 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 programming styles. Statistics: 250,000 Lines of code 2,400 classes 10,121 generic functions (and many other normal functions ...) 19,034 methods 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: N #arguments 1 21 2 15 2 13 4 11 7 10 8 9 15 8 25 7 50 6 71 5 142 4 569 3 4057 2 5168 1 Analysis: 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.