Package net.hydromatic.morel.eval
Class Applicable2<R,A0,A1>
java.lang.Object
net.hydromatic.morel.eval.ApplicableImpl
net.hydromatic.morel.eval.Applicable2<R,A0,A1>
- Type Parameters:
R- return typeA0- type of argument 0A1- type of argument 1
- All Implemented Interfaces:
Applicable,Describable
- Direct Known Subclasses:
Codes.ListNth,Codes.ListTake,Codes.RealCompare,Codes.StringSub
Applicable whose argument is a 3-tuple.
Implementations that use Applicable3 are more efficient and
concise than ApplicableImpl because there is no need to create an
ephemeral tuple (Java List) to pass the arguments, and Java's
generics provide the casting.
But the rewrite assumes that the function is strict (always
evaluates all arguments, even if the function throws) and doesn't use
EvalEnv, so it is not appropriate for all functions.
For example, andalso evaluates its
arguments lazily and therefore cannot be an Applicable2.
If a function has an Applicable2 implementation and the argument
tuple is evaluated whole, the old evaluation path will be used. For example,
the first call below uses apply and the second uses apply:
- Math.pow (2.0, 3.0);
val it = 8.0 : real
- Sys.plan ();
val it = "apply2(fnValue Math.pow, constant(2.0), constant(3.0))" : string
- Math.pow (List.hd [(2.0, 3.0)]);
val it = 8.0 : real
- Sys.plan ();
val it =
"apply(fnValue Math.pow, argCode apply(fnValue List.hd, argCode tuple(tuple(constant(2.0), constant(3.0)))))"
: string
- See Also:
-
Field Summary
Fields inherited from class net.hydromatic.morel.eval.ApplicableImpl
pos -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedApplicable2(BuiltIn builtIn) protectedApplicable2(BuiltIn builtIn, Pos pos) -
Method Summary
Methods inherited from class net.hydromatic.morel.eval.ApplicableImpl
describe, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.hydromatic.morel.eval.Applicable
asCode
-
Constructor Details
-
Applicable2
-
Applicable2
-
-
Method Details
-
apply
-
apply
-