From holland Sun Jun 19 21:30:37 1988 Return-Path: Received: by corwin.CCS.Northeastern.EDU (5.51/SMI-3.2+CCS-main-2.4) id AA11776; Sun, 19 Jun 88 21:30:30 EDT Date: Sun, 19 Jun 88 21:30:30 EDT From: holland (ian michael holland) Message-Id: <8806200130.AA11776@corwin.CCS.Northeastern.EDU> To: lieber Subject: jak Cc: oconner, riel Status: R Hi Karl, Here is my idea of a reply to jak's message. I too feel IT IS VERY IMPORTANT TO PERSUADE him to our side. I think that having read this it is important that he doesnt have the impression that we re-introduce all the stuff we were trying to avoid with the LAW. Do I acheive that goal ? I havent check for typos or spelling. Should this go into the 'formualtions' paper ? My password for all my accounts is 'fungus1', I hope Arthur can monitor my mail when I leave on thursday. So far the modems seem to be up so I should be able to comunicate with you all. Keep up the good fight and don't forget "Whatever anybody else says WE ARE STILL RIGHT !". Ian Jak's objections stem from a mis-understanding of the phrase 'objects created within the method are treated as arguements'. Our idea is that a generic funtion does not neccessarily have to have an explict 'make-instance' call (or its equivalent) to cause the creation of a new object. If the generic function has within it a call to a function which returns A Newly Created object then this too is considered a creation of an object within the generic function. Consider user defined constructor functions in C++. The example which Jak cited as being in bad style is indeed in good style, for two reasons. (defmethod sum-of-sqrt-of-difference ((x float) (y float)) (+ (sqrt (- x y)) y)) ".. since the result of applying the built-in generic function - is an argument to the SQRT generic function, as is the result of SQRT to +. The result of applying - is neither a formal parameter to the function nor is it generated within the function body itself. " 1. The type of x and y is given as float. If the result of the '-' application is an instance of type float then, according to the Law as stated in IEEE Computer this object is an instance of an argument type (float) and so it is a valid argument to the 'sqrt' function. Point 1 above is a technichal one and dependant on the Law's statement in terms of types. Point 2 is MUCH more relevant and involves the ideas above. 2. The application of the '-' to the x and y causes the creation of a new instance of the float class which is intialized to a value representing 'x - y'. So calling '-' is just the same as creating a new object and giving the instance variables of that object some intial values depending on the arguments and some procedural processing. Thus the argument to the sqrt function is again valid. The following points made by JAK are certainly very valid .. "This is exactly analogous to a user defined generic function in CLOS, since different implementations of the square root and addition algorithms will be run depending on the result of the subtraction and square root, respectively, so the actual parameters are involved in selecting the implementation. " .. and are important considerations involving the important programming techniques of functional composition and implicit case analysis. The Law of Demeter does not disallow either of the two. It is inportant to note that we haven't "thrown out the baby with the bathwater" with this interpretation of 'object creation'. A generic function has the authority to make decisions and opertate in ways which are DEPENDANT on the 'valid' objects (and their types ) i.e. like the case analysis etc above, but IS NOT ALLOWED to be dependant on the sub-parts of those objects. The deep structures of the objects are hidden from the generic function. This is a real and important restriction on the programmer. The second example given by Jak " (defmethod output-document ((switches string) (filename pathname) (printer string)) (lpr printer (troff switches filename))) (defmethod lpr ((printer string) (document stream)) <> ) (defmethod troff ((switches string) (filename pathname)) <> ) " Is again in good style when one considers the object returned from 'troff' as a new object created which is initialized to the the appropriate value.