Boost logo

Boost :

Subject: Re: [boost] [Hana] Formal review for Hana
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2015-06-18 13:15:24


Vicente J. Botet Escriba <vicente.botet <at> wanadoo.fr> writes:

>
> Le 14/06/15 21:19, Louis Dionne a écrit :
> > Paul Fultz II <pfultz2 <at> yahoo.com> writes:
> >
> >
> >> - `fold` and `reverse_fold` should be preferred over `fold_right` and
> >> ``fold_left`. This is more familiar to C++ programmers.
> > First, to my knowledge, the only libraries that even define fold and/or
> > reverse_fold are Fusion and MPL, so it's not like there was an undeniable
> > precedent for using those names instead of something else in C++. But
> > even then, `fold` and `reverse_fold` functions are provided for consistency
> > with those libraries, so I really don't see what's the problem. If you
> > prefer those names, you can use them and they have exactly the same€øÍ•µ…¹Ñ¥Ì…́ѡ•¥ÈÕÍ¥½¸½Õ¹Ñ•ÉÁ…Éи(ø5•Ñ„Ṍ͕¥Ð…±Í¼¸$´Ý½¹‘•É¥¹œ¥˜É•Ù•ÉÍ•}™½±Í¡½Õ±‘¸Ð…•ÁЁѡ”(øÍ…µ”™Õ¹Ñ¥½¸Í¥¹…ÑÕÉ”…́™½±¸%Ё͡½Õ±‘¸Ð‰”Ñ¡”…Í”™½È™½±‘}±•™Ð(ø…¹™½±‘}É¥¡Ð°…́ѡ”Á…É…µ•Ñ•É́½˜Ñ¡”™Õ¹Ñ¥½¸Ñ¼…ÁÁ±ä…É”•á¡…¹•¸()É•Ù•ÉÍ•}™½±¡…́ѡ”Í…µ”Í¥¹…ÑÕÉ”…́™½±¸%Ё‘½•Ì•á…Ñ±äÝ¡…ЁÕÍ¥½¸Ì)É•Ù•ÉÍ•}™½±‘½•Ì¸(((ø™½±±™½±¹±•™Ðé¡P§]O\¡O]SŠIL§ŠIL(ø™½±¹É¥¡Ðé¡P§]O\¡S]OŠIL§ŠIL(ø Q\°¥ÐÝ½Õ±‰”¹¥”¥˜É•Ù•ÉÍ•}™½±€¡…¹…¹ä™Õ¹Ñ¥½¸¤¡…¥Ñ́½Ý¸(øÍ¥¹…ÑÕÉ”¸(øÉ•Ù•ÉÍ•}™½±é¡P§]O\¡O]SŠIL§ŠIL()½½¥‘•„ì$Ý¥±°‘½Õµ•¹ÐÑ¡”Í¥¹…ÑÕÉ”½˜É•Ù•ÉÍ•}™½±¸M•”lÅt¸(((ø€øø€´ ½¹•ÁÑ́…É”…Á¥Ñ…±¥é•°¡½Ý•Ù•È°µ½‘•±Ì½˜„½¹•ÁЁ͡½Õ±¹½Ð‰”(ø€øø€€€…Á¥Ñ…±¥é•¡ÍՍ …́%¹ÑÉ•É…± ½¹ÍÑ…¹Ñ€°¥Ñ¡•É€Æ§–Â÷F–öæÆÀ£âãâGWÆVÂWF2£ââ–çFVw&Ä6öç7FçFÂGWÆVÂWF2âââ&RFw2W6VBf÷"FrF—7F6†–ærÀ£ââÆ–¶RgW6–öâw2fV7F÷%÷Fvbg&–VæG2â’6âwBW6RæöâÖ6—FÆ—¦V@£ââfW'6–öâ2Ö—2Â&V6W6R—Bw2vö–ærFò6Æ6‚v—F‚–çFVw&Åö6öç7FçFà£ââÇ6òÂ’f–æBF†BW6–ær6öÖWF†–ærÆ–¶RGWÆU÷Fv—2VvÆ–W"F†âW6–æp£ââGWÆVâ6öç6–FW"f÷"W†×ÆP£âà£ââÖ¶SÇGWÆU÷Fs⇇2ââ␣ââFóÇGWÆU÷Fs⇇2£âà£ââÖ¶SÅGWÆS⇇2ââ␣ââFóÅGWÆS⇇2£â’v÷VÆB&VfW"öb†æW6W2öæÇ’6ÖVÄ66Rf÷"2²³ró#6öæ6WG2÷"f÷ £â2²³BG—R&WV—&VÖVçG2âF†—2v–ÆÂ&R6öægW6–ærf÷"Ö÷&RF†âöæRà£à£â–÷R†fRÇ6òF†R÷F–öâFòFVf–æRÖ¶R†f–ær6Æ72FV×ÆFR0£â&ÖWFW"…6VR´Ò’à£à£âÖ¶SÅ÷GWÆS⇇2ââ␣âFó\OŠÊB‚’[ˆ[˜KXZÙX\ÈH˜\šXX›H[\]H[™XZÙO ‹‹˜\ÈH[˜Ý[ۈؚ™XÝ ‚•[™›Ü[˜][K\ÈYX[œÈ]ÙH]™HÈXZÙHHÚÚXÙH™]ÙY[ˆXØÙ\[™Â˜H\H[\]H\˜[Y]\ˆ܈H[\]H[\]H\˜[Y]\‹]›Ý›Ý ‚‚ˆË‹‹—B‚ˆHÛÝ[™Y™\ˆ[ÛÈ][˜HYš[™\È]ÈÛۘܙ]H\\˝]H[šÂˆ\Ș]H\ÈÜÝ ‚‚’]\Û‰ÝHÜݘ]KˆHÛÝ[[ÛÈ™Y™\ˆÈYš[™H^HÛۘܙ]H\\˘™[Y]™HYK]IÛH›ÝÝ\™HÝÈÈÈ]Ú]Ý]ØÜ™]Ú[™È\Ù\œÈ\ ˆ\™B˜\™H[ÛÈÛÛYHÛÛ\[K][YH\ÜÝY\ÈÚ]ÜXÚYžZ[™ÈÛۘܙ]H\\È[ˆÛÛYB˜Ø\Ù\ˈ›Üˆ^[\KØ^HHÜXÚYžHHÛۘܙ]H\HÙˆHÙ]\ÈÜÙ] ‹‹˜ ˜[™HÛۘܙ]H\HÙˆ[ÏO˜\ÈÚ[O˜ ˆ[‹[ÝIÜ™H[ÝÙYÈÜš]BH›ÛÝÚ[™È
܈\™H[ÝOÊN‚‚ˆ]]ÈÈana::make_set(int_<1>, int_<2>, int_<3>);
    hana::_set<_int<3>, _int<2>, _int<1>> ys = xs;

Should this work? Well, sort of, because the order of elements inside a Set
is unspecified, so any permutation of

    hana::_set<int_<1>, int_<2>, int_<3>>

should be a valid receiver type for `xs`. But this seemingly naive assignment
bears a considerable compile-time cost, since you have to assign each
corresponding element from `xs` into `ys`, element by element. It's just
a can of worms, and I'm sure there's a right way to open it but for now I
have decided to leave it closed.

> >> - IntregralConstant is very strange. In Hana, its not a concept(even
> >> though its capitalized), but rather a so called "data type".
> >> Furthermore, because of this stran¹•Í́¥Ð‘½•Í¸Ð¥¹Ñ•É½Á•É…Ñ”Ý¥Ñ (ø€øø€€½Ñ¡•È%¹ÑÉ•É…± ½¹ÍÑ…¹ÑÌ¡ÍՍ …́™É½´Q¥¬¤•Ù•¸Ñ¡½Õ …±°Ñ¡”(ø€øø€€½Á•É…ѽÉ́…É”‘•™¥¹•¸(ø€ø%¹Ñ•É…± ½¹ÍÑ…¹Ð¥Ì¹½Ð„½¹•ÁаÑ¡…Н́ÑÉÕ”¸Q¡”™…ÐÑ¡…Ё¥Ð‘½•Ì¹½Ð(ø€ø¥¹Ñ•É½Á•É…Ñ”Ý¥Ñ Q¥¬Ì%¹Ñ•É…± ½¹ÍÑ…¹Ñ́½Õе½˜µÑ¡”µ‰½à¡…́¹½Ñ¡¥¹œÑ¼(ø€ø‘¼Ý¥Ñ Ñ¡…а¡½Ý•Ù•È¸e½ÔµÕÍЁµ…­”å½ÕȁQ¥¬¥¹Ñ•É…°½¹ÍÑ…¹Ñ́„µ½‘•°(ø€ø½˜!…¹„Ì ½¹ÍÑ…¹Ð½¹•ÁЁ™½È¥ÐÑ¼Ý½É¬¸M•”Ñ¡”¥ÍЁ…ЁlÉt™½È¡½ÜÑ¼(ø€ø‘¼Ñ¡…и(øQ¡¥Ì¥Ì…Á¥Ñ…°Ñ¼Ñ¡”Õ¹‘•ÉÍÑ…¹‘¥¹œ½˜!…¹„¸!…¹„¡…́¹¼…Õѽµ…Ñ¥Œ(øµ…ÁÁ¥¹œ¸e½ÔµÕÍЁÍÑ…Ñ”•áÁ±¥¥Ñ±äÑ¡…Ё„ÑåÁ”¥Ì„µ½‘•°½˜„ ½¹•ÁÐ(ø…¹$±¥­”¥Ð¸Q¡¥Ì‘½•Í¸Ð™½±±½Ü¡½Ý•Ù•ÈÑ¡”ÕÉÉ•¹ÐÑÉ•¹½˜ ¬¬ÄܼÈÀ(ø ½¹•ÁÑ̸(ø(øÑåÁ”¥Ì„µ½‘•°½˜„ ½¹•ÁЁ¥Ì¥Ð¡…́…¸•áÁ±¥¥Ðµ…ÁÁ¥¹œ½˜¥ÑÌ(ø…Í6–FVBÖ–ær7G'V7GW&Rà£à£âF†R6öç7FçB6öæ6WB6÷VÆB†fRÖ6BF†BFVfVÇG2FòF†RæW7FV@£âÖVÖ&W'2ÂæB6òÖ¶RV6–W"–÷W"Ö–ærà ¥–÷Rw&R&–v‡BÂ’wfR&VVâF†–涖ær&÷WBF†BâF†—2&ö×G2ÖRFò÷VâF†—0¦—77VR³%Òà  £â’v÷VÆB&VfW"–b†æW6VBF–ffW&VçBæÖRf÷"†—26öæ6WG2â–à£âFF—F–öâ†æ6öæ6WG2†fRâ76ö6–FVB6Æ72Âv†–6‚2²³ró#6öæ6WG0£â&R&VF–6FW2à£â’v÷VÆB&W6W'fRF†R6ÖVÄ66Rf÷"2²²6öæ6WG2æBF†RÆ÷vW&66Rf÷"F†P£âÖ–ær7G'V7BÀ£à£â7G'V7BÆ–6F—fR°£âFV×ÆFRÇG—VæÖRà£â7G'V7BG&ç6f÷&Õö–×ð£âÓ°£à£âFV×ÆFRÇG—VæÖRcà£â6öæ6WB&ööÂÆ–6F—fRÒ&WV—&W2âââã° ¤’F†–æ²—Bv÷VÆB&R&WGFW"Fòv—BVçF–ÂvRö7GVÆÇ•ò†fR6öæ6WG2–à§F†RÆæwVvR&Vf÷&RG'–ÈÈ[][]H[HÛÈ\™ ˆH[šÈ]\ÈÛÛٝ][˜HÙ\țݙ][™È]™HÛÛ˜Ù\È
[ˆHÛÛ˜Ù\Ë[]HÙ[œÙJK‚‘Ú[™ÈÝ\Ú\ÙHÛÝ[™HZ\ÛXY[™Ë‚‚ˆË‹‹—B‚ˆˆ HÛÛ˜Ù\ÈXZÙH›ÈY[[ÛˆÙˆZ[š[][H\H™\]Z\™[Y[ÝXÚ\ˆˆ[Ý™PÛۜݝXÝX›K‚ˆˆH™[Y]™HHšYÚXÙHÈ]\ÈÛÝ[™H[ˆHØÝ[Y[][ÛˆÙ‚ˆˆÛۘܙ]H[Ù[ÈZÙH\X ]›Ý[ˆHÛÛ˜Ù\È
ZÙHÙ\]Y[˜ÙX
K‚ˆˆ[˜IÜÈÛÛ˜Ù\ÈÜ\˜]H]HÛYÚHYÚ\ˆ]™[[™^HțݙX[Bˆˆ]™HH›Ý[ÛˆÙˆÝܘYÙKˆ]HYÜ™YH]]\È™XÙ\ÜØ\žHÈØÝ[Y[ˆˆ\ÙH™\]Z\™[Y[ˈX\ÙH™Y™\ˆÈ\È\ÜÝYHÍ—H›ÜˆÝ]\Ë‚ˆ‚ˆHÛ‰ÝÛ›ÝˈHÛۜݘZ[È]\Ý™HÝ]YÚ\™H™YYY ˆ\™H\țˆ™X\ÛÛˆHÛÛ˜Ù\ÚÝ[‰Ý™\]Z\™H]H[™\›g type is a model
> of some other Concept it this is needed. I believe that all the concepts
> make use of MoveConstructible types, or am I wrong. I agree that the
> documentation is not precise enough respect to this point.

I'm not saying that e.g. Iterable _should not_ document these constraints,
I'm just saying it does not, at the moment, operate at such a low level.
For example, an infinite stream generating the Fibonacci sequence could be
a model of Iterable, but there is no notion of storage in this case. However,
like I said, I agree that these requirements must be documented where they
exist.

> [...]
>
> This doesn't mean that we can not have an index of all the algorithms.

An index of all the algorithms will be done.

> [...]
> > 2. Concaten¥¹œÍÑÉ¥¹Ìµ…­•Ì½µÁ±•Ñ”Í•¹Í”°¥¹‘••¸Q¡¥Ì½Õ±‰”(ø€ø€€€€¡…¹‘±•Ù•É䁹…ÑÕÉ…±±ä‰ä‘•™¥¹¥¹œ„5½¹½¥‘€µ½‘•°°‰ÕЁ¥ÐÝ…́¹½Ð(ø€ø€€€€‘½¹”‰•…ÕÍ”$‘¥¹½Ð±¥­”ÕÍ¥¹œ€­€™½È½¹…Ñ•¹…Ñ¥¹œÍÑÉ¥¹Ì€¸$(ø€ø€€€€½Á•¹•Ñ¡¥Ì¥ÍÍÕ”látÑ¼ÑÉ䁅¹™¥¹„ÁɽÁ•ÈÉ•Í½±ÕÑ¥½¸¸(ø$µ¥ÍÍ•Ñ¡”™…ÐÑ¡…Ё5½¹½¥¥¹Ñɽ‘Ս•Ì€¬™½ÈÁ±Õ̸Q¡”½Á•É…ѽȬµÕÍÐ(ø‰”‘½Õµ•¹Ñ•…¹…ÁÁ•…ȁ½¸Ñ¡”5½¹½¥™½±‘•È¸(ø(ø$Ý½Õ±‘¸Ð‰”Ý•¥ÉÑ¼ÕÍ”€¬™½È½¹…Ñ•¹…Ñ¥¹œÍÑÉ¥¹Ì…́ÍѐèéÍÑÉ¥¹œ(øÁɽ٥‘•Ì…±É•…‘䁽Á•É…ѽȬ ¤¸%Ёݽձ‰”µÕ µ½É”Ý•¥ÈÑ¼ÕÍ”(øé•É¼½Á±Õ̼¬Ý¥Ñ „µ½¹½¥€¡¥¹Ð°€¨°€Ä¤(ø(øQ¡¥Ì¥ÌÑ¡”Áɽ‰±•´½˜¹…µ¥¹œÑ¡”™Õ¹Ñ¥½¸…Íͽ¥…Ñ•Ñ¼„ ½¹•Áи(ø(ø!…Í­•±°Ṍ͕µ…ÁÁ•¹…¹µ•µÁÑäüQ¡•Í”¹…µ•Ì½µ•Ì™É½´Ñ¡”1¥ÍЁ5½¹½¥¸(ø$‘½¸Ð±¥­”Ñ¡•´¹•¥Ñ¡•È¸(ø%5!<°ÑæÖW2öbÖöæö–B÷W&F–öç2×W7B&R–æFWVæFVçBöbF†RFöÖ–âà£âÖöæö–B—2G&—ÆWB…BÂ÷ÂæWWG&Â’Âv†W&R÷—2&–æ'’÷W&F–öà£âöâBæBæWWG&—2F†RæWWG&ÂVÆVÖVçBB&W7V7BFòF†—2÷W&F–öâà£âv†B—2w&öærF†Vâv—F‚Ööæö–C£¦÷æBÖöæö–C£¦æWWG&–ç7FVBöbF†P£â†ævÆö&Ç2ÇW2æB¦W&óòFöòfW&&÷6Sò†f–ærF†W6RæÖW2öâ£âæÖW76RÆWBF†RW6W"Ö¶RF†R6†ö–6Rà ¤—B&V6öÖW2w&öærv†Vâ–÷R†fRÖ÷&R6ö×ÆW‚G—R6Æ76W2â†÷rv÷VÆB–÷P¦6ÆÂF†R&–ærw2÷W&F–öâæB–FVçF—G“òæB†÷rv÷VÆB–÷R6ÆÂF†P¦÷W&F–öç2öbÖöæCòWFæB×R2F†RÖF†VÖF–6–ç2Fò—Còæò§F†–æ²vR†fRFòWB7GVÂæÖW2B6öÖRö–çBÂWfVâ–bF†BÖVç0¦Æ÷6–ær6öÖRvVæW&Æ—G’à  £â’v÷VÆBæ÷B&÷f–FRç’÷W&F÷'2f÷"F†RÖöæö–B6öæ6WBà ¤’ÒF†–涖æX›Ý]\ÜÛØÚX][™ÈHÜ\˜]ܜȜ›ÛHHÛÛ˜Ù\ț܂XÚšXØ[™X\ÛÛœÎÈÙYHÌ×Kˆ[œÝXY Ü\˜]ÜœÈÛÝ[™H[™Y›Ü‚™XXÚ]H\K‚‚ˆˆ™YØ\™[™È˜\šXX›H[\]\È[™Ñ‹HÝYÚ˜\šXX›H[\]\ÈÛÝ[‰ÝˆˆXYÈшš[Û][ÛœÏÈHÛ›ÝÈÛؘ[[˜Ý[ۈؚ™XÝÈ
]™[ˆÛÛœÝ^ŠHØ[‚ˆˆXYÈшš[Û][ۜ˝]HØ\Û‰Ý]Ø\™HX›Ý]H›Ø›[H›Üˆ˜\šXX›Bˆˆ[\]\ˈHÛÝ[\™XÚX]HYˆ[ÝHÛÝ[ÚÝÈYHÚ\™HH›Ø›[HY\ˆˆ[Ü™HÜXÚYšXØ[Kˆ[Û˛܈™Y™\™[˜ÙK\™IÜÈHY™XÝ™\ܝÎWH™[]YˆˆÈÛؘ[ÛÛœÝ^ˆØš™XÝË[™[ˆ\ÜÝYH˜XÚÚ[™È\ț؛[H\™HÌLK‚ˆ‚ˆš[˜[K™YØ\™[™È^XÝ]X›H›Ø] ÙIÜ™H[Ú[™ÈX›Ý]Ý][\ÜÈÛÛœÝ^‚ˆˆØš™XÝÈ\™Kˆ]ÛÜœÝ ÙIÜ™H[Ú[™È Hž]H\ˆØš™XÝ ˆ]™\(and most
> > likely), we're talking about 0 bytes because of link time optimizations.
> > Otherwise, I could also give internal linkage to the global objects and
> > they would probably be optimized away by the compiler itself, without even
> > requiring LTO. Am I dreaming?
> The best is to measure it Are there any measures of the same program
> using Hana and Meta?

It goes without saying that Meta will have 0 runtime overhead, since it's
purely at the type level. The only question is whether Hana can do just as
well. From my micro-benchmarks, I know Hana can do just as good in those
cases. However, it is hard to predict exactly what will happen for non
trivial programs. I think compressing the storage of empty types should
make it much, much easier foÑ¡”½µÁ¥±•ÈÑ¼½ÁÑ¥µ¥é”•Ù•ÉåÑ¡¥¹œ…Ý…ä¸()±Í¼°±¥­”$Í…¥¥¸…¹½Ñ¡•È…¹ÍݕȁѼI½±…¹°¥Ð¥Ì…±Ý…ǻÁ½ÍÍ¥‰±”Ñ¼)•¹±½Í”…¹äÙ…±Õ”µ±•Ù•°½µÁÕÑ…Ñ¥½¸¥¸‘•±ÑåÁ•€Ñ¼•¹ÍÕÉ”Ñ¡…Ё¹¼½‘”)¥Ì…ÑÕ…±±ä•¹•É…Ñ•¸ ÕЁ½˜½ÕÉÍ”Ñ¡¥Ì¥ÌÍ±¥¡Ñ±ä…¹¹½å¥¹œ¸(()I•…É‘Ì°)1½Õ¥Ì(()lÅt聡ÑÑÁÌè¼½¥Ñ¡Õˆ¹½´½±‘¥½¹¹”½¡…¹„½¥ÍÍՕ̼ÄÌÄ)lÉt聡ÑÑÁÌè¼½¥Ñ¡Õˆ¹½´½±‘¥½¹¹”½¡…¹„½¥ÍÍՕ̼ÄÌÈ)lÍt聡ÑÑÁÌè¼½¥Ñ¡Õˆ¹½´½±‘¥½¹¹”½¡…¹„½¥ÍÍՕ̼ÄÌà


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