| <<O>> Difference Topic DispatchIntermediateExample (r1.2 - 24 Dec 2003 - IsaacGouy) |
| Changed: | |
| < < | multiply1(this@Real, other@Real) = |
| > > | multiply1(Real this, Real other) = |
| Changed: | |
| < < | multiply1(this@Integer, other@Integer) = |
| > > | multiply1(Integer this, Integer other) = |
| Changed: | |
| < < | multiply1(this@Integer, other@Rational) = |
| > > | multiply1(Integer this, Rational other) = |
| Changed: | |
| < < | multiply1(this@Rational, other@Integer) = |
| > > | multiply1(Rational this, Integer other) = |
| Changed: | |
| < < | multiply1(this@Rational, other@Rational) = |
| > > | multiply1(Rational this, Rational other) = |
| <<O>> Difference Topic DispatchIntermediateExample (r1.1 - 19 Sep 2003 - IsaacGouy) |
| Added: | ||||||||||||||||||||||||||||||||||
| > > |
%META:TOPICINFO{author="IsaacGouy" date="1064012340" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="CodeExamples"}%
The original MultiJava code for this benchmark, and the Java comparison code, is available from this Technical Report:
"MultiJava: Design, implementation, and evaluation of a Java-compatible language supporting modular open classes and symmetric multiple dispatch", Curtis Clifton, Iowa State University TR #01-10, November 2001. ftp://ftp.cs.iastate.edu/pub/techreprts/TR01-10/TR.pdf Curtis Clifton kindly gave permission for this use. The performance ratios for MultiJava and Nice are very different - the results are from different machines, and different test iterations but that doesn't seem like an adequate explanation.
Multiple DispatchThe typecases and double-dispatch implementations are given in the MultiJava report. A single line was changed in both of the Java test driver classes Exercise.java and TestMultipleDispatch.java (to call the Nice multi-dispatch method):Real result = values[i].multiply1(values[j]);was changed to Real result = dispatch.multiply1(values[i],values[j]);The multi-dispatch methods were placed together in a separate file. That is different to the MultiJava implementation:
// compilation unit multiply1.nice
package multipledispatch;
import multipledispatch.*;
// Methods using multiple dispatch
Real multiply1(Real this, Real other);
multiply1(this@Real, other@Real) =
new Real(this.value * other.value());
multiply1(this@Integer, other@Integer) =
new Integer(lValue * other.getLValue() );
multiply1(this@Integer, other@Rational) =
new Rational(lValue * other.numerator(), other.denominator() );
multiply1(this@Rational, other@Integer) =
new Rational( this.numerator * other.getLValue(),
this.denominator );
multiply1(this@Rational, other@Rational) =
new Rational( this.numerator * other.numerator(),
this.denominator * other.denominator() );
long getLValue(Integer) = native long multipledispatch.Integer.lValue();
-- IsaacGouy - 19 Sep 2003 | |||||||||||||||||||||||||||||||||
| Topic DispatchIntermediateExample . { View | Diffs | r1.2 | > | r1.1 | More } |
|
Revision r1.1 - 19 Sep 2003 - 22:59 GMT - IsaacGouy Revision r1.2 - 24 Dec 2003 - 21:32 GMT - IsaacGouy |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |