4.6 Eager evaluation

Prev Up Next Page 32 of 800 Search internet

As a programmer, you will use Logiweb for eager programs most of the time. That is because eager programs run faster than lazy ones, at least with present day hardware. The lgc compiler produces the best code when applied to eager programs.

The base page defines an eager define X as Y end define construct which ensures X to be defined as an eager function which evaluates its arguments in sequence before invoking the function itself. The sequential order is important because if evaluation of an argument results in an exception, the remaining arguments are not evaluated.

Eager functions operate on 'eager data'. Eager data constitutes a subset of the values expressible by extended lambda terms. Eager data contains 'tags' which represent data types to be checked at run-time. As an example, adding a Boolean and an integer yields an exception where Booleans, integers, and exceptions have different tags.

To provide a maximum of flexibility, Logiweb allows to embed eager data in lazy data and vice versa. Embedding eager data in lazy data is trivial since eager data constitutes a subset of lazy data. Embedding lazy data in eager data is done by adding a 'maptag' to the lazy data. The 'maptag' is a tag which tells the computing engine that the tagged data is lazy data. When the computing engine meets a maptag, it stops computing eagerly.

Prev Up Next Page 32 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05