Boost logo

Boost :

From: Vesa Karvonen (vesa_karvonen_at_[hidden])
Date: 2002-04-08 02:13:22


David Abrahams:
>Man, the doc for this library is still hard to use! It's like a
>tempting treat that's just out-of-reach. Memnonic names instead of
>single letters for the parameters would really help a lot!

I'll see what can be done.

>Is there an operation like "bind" for the PP lib?

I recall implementing some experimental macros for closures, but I think
that they were very limited in capability and suffered badly from the
limitation that the same macro can not be expanded twice. Since I couldn't
think of a robust enough way to implement closures, I dropped the idea.

I recall the basic idea was to represent a closure as a tuple:

  (PARAMS_NEEDED,MACRO,BOUND_PARAMS)

Then a macro, CALL, was used for expanding closures:

  CALL(CLOSURE,PARAMS)

The CALL macro would either expand to a new closure (appending PARAMS to
BOUND_PARAMS and decrementing PARAMS_NEEDED cnt) or expand the MACRO of the
closure if there were enough parameters.

The main problems with this approach are:
- calling a closure requires special syntax
- CALL can not be expanded recursively

In order to avoid the expansion problem, it might be possible to do
something like this:

  CALL_CLOSURE(CLOSURE,PARAMS) WITH_PARAMS(CLOSURE,PARAMS)

The trick is that neither the CALL_CLOSURE nor the WITH_PARAMS are actually
expanded recursively. Rather the macro expansion occures during a subsequent
rescan.

The main problem remains that calling a closure does not use the same syntax
as calling an ordinary macro.

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk