kirby urner wrote: >> ifTrue:[^self scalarAdd: aNumericObject] >> ifFalse:[^self vectorAdd: aNumericObject]. >> >>and then: >> >>Vector>>scalarAdd: aNumber >> x := x + aNumber. >> y := y + aNumber. >> z := z + aNumber. >> >>Vector>>vectorAdd: aVector >> x := x + aVector x. >> y := y + aVector y. >> z := z + aVector z. >> >>The case analysis in Vector>>+ can be quite annoying so often there are >>other techniques (like double-dispatching) used to implement the proper >>coercion. The common technique currently used by Squeak coerces based on >>generality, so to implement the "reverse" set of operations you'd do, e.g., >> >>Vector>>adaptToNumber: aNumber andSend: aSymbol >> "If I am involved in arithmetic with a scalar, return a Vector of >> the results of each element combined with the scalar in that >> expression." >> ^Vector >> x: (x perform: aSymbol with: aNumber) >> y: (y perform: aSymbol with: aNumber) >> z: (z perform: aSymbol with: aNumber) >> >> At what point does it become appropriate to expect this conversation to move over to "Squeakland" - where kids who are different than I was are treated without condescension.
Art _______________________________________________ Edu-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/edu-sig
