Boost logo

Boost :

Subject: Re: [boost] Hana Views and References
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2015-06-25 17:24:26


Joel de Guzman <djowel <at> gmail.com> writes:

>
> Hello Louis,
>
> Mario Lang, a Spirit developer, played around with Hana and
> investigated on it's suitability for Spirit. His conclusion
> is that "Hana is really quite nice!". Then, he adds that:
> "However, Hana lacks a way to retrieve the members of a
> struct as references currently, which will pretty much kill
> a Hana based Spirit effort."

Indeed, this will change once this issue [1] is resolved.

> So the question is: will Hana support references without
> resorting to using reference wrappers? I do appreciate
> the FP nature of Hana, but please be reminded that we're
> in C++.
>
> I also recall some discussion that Hana also does not support
> Fusion-like lightweight views. Is there a plan to support them?

If we find use cases where views would really be helpful, then that's
a feature that could be added. I'm open to the possibility, but right
now there are (1) more urgent things to improve (2) no clear use case
that require views. However, I haven't given a lot of thought to it,
so I might be missing some obvious use cases.

Also note that views like in Fusion would actually take Hana further
away from C++, where we are used to eager evaluation. Adding laziness
to Hana would give it an even more FP taste. This is just an observation.

> I haven't fully investigated yet what else Hana does not support
> that Fusion does, but at least these two important aspects of
> fusion come to mind. At the very least, I don't think Hana should
> advertize itself as a superset of Boost.Fusion.

The first aspect is a bug, and the second aspect is more like a different
design choice, since Fusion supports only "lightweight views", and no
eager algorithms. What is meant is that all of Fusions's algorithms are
implemented in Hana (and more), which is true. I don't think saying Hana
is a superset of Fusion is detrimental to Fusion, but I could reword that
sentence of the tutorial if you feel like it is detrimental.

> Faster runtime performance is also questionable, when lightweight
> views and reference members come into play.

Hana claims to be at least as good as Fusion runtime-wise, which is
backed by the benchmarks presented in the tutorial. It is possible
that idiomatic usage of Hana leads to worse runtime performance than
with Fusion, in which case the library and its idioms will have to be
adjusted. Like I said a few times, Hana is a new library with a new
paradigm, and I think we're only starting to discover how it can be
used (and used efficiently).

Regards,
Louis

[1]: https://github.com/ldionne/hana/issues/90


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