[nhc-users] _apply1 and _apply2
Malcolm Wallace
Malcolm.Wallace@cs.york.ac.uk
Fri, 12 Apr 2002 14:52:21 +0100
Saswat Anand <saswat@comp.nus.edu.sg> writes:
> Could you explain when the compiler inserts _apply1 and _apply2.
These are inserted during lambda-lifting, to ensure the correct
laziness of certain applications.
> As _apply2 f a b = _apply1 (_apply1 f a) b, how is _apply2 useful?
Evaluating
_apply2 f a b
is slightly more efficient at runtime than evaluating the nested application
_apply1 (_apply1 f a) b
Time profiling shows that, for many programs, _apply1 and _apply2
take a significant percentage of the total runtime, so it is wise to
avoid extra runtime costs wherever possible, since their only purpose
is to introduce a lazy suspension for semantic correctness.
Regards,
Malcolm