Boost logo

Boost :

Subject: Re: [boost] [Hana] Informal review request
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2015-03-22 17:44:56


Louis Dionne <ldionne.2 <at> gmail.com> writes:

>
> Dear Boost,
>
> Here is a non-exhaustive list of some issues that were raised during
> the informal review of Hana last week, along with an explanation of
> what I did or am doing to resolve them.
>
> [...]
>
> 4. It was suggested that `foldl` and `foldr` be renamed to something else.
> [...]

fold/reverse_fold aliases are now provided (see [1] for commit). Those
aliases follow the behavior of Fusion/MPL closely, with the extension
that it's possible to provide no initial state. Specifically,
    
    fold(sequence, state, f) == foldl(sequence, state, f)
    fold(sequence, f) == foldl1(sequence, f)

    reverse_fold(sequence, state, f) == foldr(sequence, state, flip(f))
    reverse_fold(sequence, f) == foldr1(sequence, flip(f))

> 7. In a different thread [6], it was suggested that the Logical concept
> should interact well with Lazy computations. [...]

Arbitrary Lazy values and computations can now be used as branches to
`eval_if` (see [2] for commit). More generally, anything that can be
`eval`uated can be used as branches to `eval_if`, which means

nullary lambdas:

    eval_if(condition,
        []{ return something; },
        other_branch
    )

unary lambdas (useful for delaying instantiations, explained in the docs):

    eval_if(condition,
        [](auto delay) { return delay(f)(something); },
        other_branch
    )

Lazy computations/values:

    eval_if(condition,
        lazy(f)(x, y, z),
        other_branch
    )

More syntactic sugar will probably be added so that `eval_if` looks
prettier. Something along the lines of

    eval_if(condition)([]{
        branch1

    }).else_([]{
        branch2
    })

would be nice. I got this functionality (and more) locally, but I
want to study all the possibilities before I check something in.

Regards,
Louis Dionne

[1]: http://goo.gl/6hIWrA
[2]: http://goo.gl/6yEhAz


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