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
public abstract class Applicable2<R,A0,A1> extends ApplicableImpl
Applicable whose argument is a 3-tuple.Implementations that use
Applicable3are more efficient and concise thanApplicableImplbecause there is no need to create an ephemeral tuple (JavaList) 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,andalsoevaluates its arguments lazily and therefore cannot be anApplicable2.If a function has an
Applicable2implementation and the argument tuple is evaluated whole, the old evaluation path will be used. For example, the first call below usesapplyand the second usesapply:- 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:
Applicable3
-
-
Field Summary
-
Fields inherited from class net.hydromatic.morel.eval.ApplicableImpl
pos
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedApplicable2(BuiltIn builtIn)protectedApplicable2(BuiltIn builtIn, Pos pos)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Rapply(A0 a0, A1 a1)Objectapply(EvalEnv env, Object argValue)-
Methods inherited from class net.hydromatic.morel.eval.ApplicableImpl
describe, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.hydromatic.morel.eval.Applicable
asCode
-
-