diff options
author | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-04-23 08:15:17 +0000 |
---|---|---|
committer | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-04-23 08:15:17 +0000 |
commit | 072455265526c994fb39221624209a3180b41837 (patch) | |
tree | f1d07a995e7668f97246975bc3867e4ef4196a1b /src/build | |
parent | d8342f44a77d0cb2780c1681e114fe2258a3dcb4 (diff) | |
download | scala-072455265526c994fb39221624209a3180b41837.tar.gz scala-072455265526c994fb39221624209a3180b41837.tar.bz2 scala-072455265526c994fb39221624209a3180b41837.zip |
Modified the implementation of curry so that for
FunctionN, where N > 4, many fewer classes are created statically at the
expense of creating more objects dynamically (which seems reasonable
given how common such functions are likely to be). This also allows for
curry in FunctionN for N > 8 without running into the filename length
restriction.
Diffstat (limited to 'src/build')
-rw-r--r-- | src/build/genprod.scala | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala index 1a78fa532d..e2ee048a03 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -142,7 +142,7 @@ package scala * </p> * {descriptiveComment(i)} */ -trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ +trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ self => def apply({__funArgs__}): R override def toString() = "<function>" {moreMethods(i)} @@ -160,12 +160,16 @@ trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ */ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) } """ - case _ if (i > 1) && (i < 9) => """ + case _ if (i > 1) => """ /** f(""" + join(",", (1 to i).map(i => "x" + i)) + """) == (f.curry)""" + join("", (1 to i).map(i => "(x" + i + ")")) + """ */ - def curry: """ + join(" => ", (1 to i).map(i => "T" + i)) + """ => R = { """ + - join(" => ", (1 to i).map(i => "(x" + i + ": T" + i + ")")) + """ => apply(""" + join(",", (1 to i).map(i => "x" + i)) + """) } -""" + def curry: """ + join(" => ", (1 to i).map(i => "T" + i)) + """ => R = { +""" + + (if (i < 5) { + " " + join(" => ", (1 to i).map(i => "(x" + i + ": T" + i + ")")) + """ => apply(""" + join(",", (1 to i).map(i => "x" + i)) + ")\n }" + } else { + """ (x1: T1) => ((""" + join(", ", (2 to i).map(i => "x" + i + ": T" + i)) + """) => self.apply(""" + join(",", (1 to i).map(i => "x" + i)) + ")).curry\n }" + }) case _ => """ """ |