{ x+y }Since the add doesn't involve the (empty) parameter, it is a subexpression of closure creation, not of closure execution. In an eager environment we mightn't want to do the add until the closure is called to avoid doing it unnecessarily (this would be more clear if it was a more expensive operation). But (yet another) nice thing about being lazy is that we can do these things correctly without cost (apart from the cost of laziness itself).
It is not so easy to switch Wombat to being lazy. The intention was that the language would have 3 levels:
- A very low level that maps directly to the particular hardware format. Let me call this a grade in Mercury style. This is the primitive procedures and types that vary with grade.
- The next level up is C-like and abstracts out the grade-specific crud, but still doesn't provide a safe programming environment for most uses.
- At the top level we have types and operations with mathematically nice semantics, designed for most uses. This is where laziness might be appropriate.
No comments:
Post a Comment