| Search internet |
Recall the basic constructs which allows to express all maps (i.e. all raw maps):

Programming from the four basic constructs is possible, but does not lead to very efficient programs. If one references the base page then one gets acces to e.g. falsehood defined thus:

Once
is recognized as a built in construct, the Logiweb abstract machine does not really use the definition of falsehood given above but, rather, uses a built in version which typically leads to programs running much faster.
To define a new function which also runs fast, use the eager definition construct
like in the following definition of append:

The eager definition construct
is macro defined on the base page; it expands into an ordinary value definition which, however, lgwam can recognize as something it can optimize heavily.
In eager definitions you can use most of the built in constructs. Furthermore, you can use other functions which are defined by the eager definition construct. If in doubt if a construct can be used, just try it. The lgc compiler while whine if it sees something that looks like an eager definition but which the lgc compiler nevertheless finds to be unfit for optimization.
When the lgc compiler sees something that looks like an eager definition, it checks whether or not the definition is fit for optimization. It does so used fitness analysis which is similar to more traditional strictness analysis.
Stating a definition which looks eager but which is unfit for optimization is no error, so the lgc compiler just issues a probably mistakenly unfit warning to tell you that lgc thinks you might have done something you did not intend. But when this happens, lgc just compiles the definition without optimizations and continues since you might after all know what you are doing.
All functions defined using
are eager left-relaying in that they compute their arguments left to right and relay exceptions. If you need to define a construct which is not eager left-relaying but which you still want to be fast, chances are you should macro define your construct rather than giving a value definition.
| Search logiweb.eu |