[PRL] laziness

David A. Herman dherman at ccs.neu.edu
Wed Jun 23 13:53:41 EDT 2004


> In Haskell, of course, `if' is syntax, not a function,
> because of the `then' and `else' tokens.  You could
> write a lambda wrapper around `if', if that's what
> you really want.

Okay, but `when' and `unless' are functions, which supports the spirit of
Johan's point.

While `if' doesn't impress Richard, the point is that some of the examples
of things you have to implement in macros can be implemented with regular
functions. This is a good thing, I suppose. But as Oleg points out, macros
can abstract over *second-class* language constructs, and lazy functions
can't:

    http://okmij.org/ftp/Scheme/macros.html#Macro-CPS-programming
    http://okmij.org/ftp/papers/Macros-talk.pdf

Haskell functions can't abstract over type declarations, for example. Oleg
notes that the use of a preprocessor in the implementation of the GHC
compiler is an indication of the usefuless of macros beyond what laziness
can buy you.

Dave



More information about the PRL mailing list