|
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]SIL§IL(ø½±¹É¥¡Ðé¡P§]O\¡S]OIL§IL(ø Q\°¥Ðݽձ¹¥¥ÉÙÉÍ}½±¡
¹
¹äչѥ½¸¤¡
¥Ñ̽ݸ(øÍ¥¹
ÑÕɸ(øÉÙÉÍ}½±é¡P§]O\¡O]SIL§IL()½½¥ì$Ý¥±°½Õµ¹ÐÑ¡Í¥¹
ÑÕɽÉÙÉÍ}½±¸MlÅt¸(((øøø´
½¹ÁÑÌ
É
約
±¥é°¡½ÝÙÈ°µ½±Ì½½¹ÁÐÍ¡½Õ±¹½Ð(øøø
約
±¥é¡ÍÕ
Ì%¹ÑÉÉ
±
½¹ÍÑ
¹Ñ°¥Ñ¡ÉƧÂ÷FöæÆÀ£âãâGWÆVÂWF2£ââçFVw&Ä6öç7FçFÂGWÆVÂWF2âââ&RFw2W6VBf÷"FrF7F6ærÀ£ââƶRgW6öâw2fV7F÷%÷Fvbg&VæG2â6âwBW6RæöâÖ6FƦV@£ââfW'6öâ2Ö2Â&V6W6RBw2vöærFò6Æ6vFçFVw&Åö6öç7FçFà£ââÇ6òÂfæBFBW6ær6öÖWFærƶRGWÆU÷Fv2VvÆW"FâW6æp£ââGWÆVâ6öç6FW"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²³BGR&WV&VÖVçG2âF2vÆÂ&R6öægW6ærf÷"Ö÷&RFâöæRà£à£â÷RfRÇ6òFR÷FöâFòFVfæRÖ¶Rfær6Æ72FV×ÆFR0£â&ÖWFW"
6VR´Òà£à£âÖ¶SÅ÷GWÆSâ2âââ£âFó\OÊB[[KXZÙX\ÈH\XXH[\]H[XZÙO\ÈH[Ý[ÛØXÝ[Ü[][K\ÈYX[È]ÙH]HÈXZÙHHÚÚXÙH]ÙY[XØÙ\[ÂH\H[\]H\[Y]\ÜH[\]H[\]H\[Y]\]ÝÝËBHÛÝ[Y\[ÛÈ][HY[\È]ÈÛÛÜ]H\\Ë]H[Â\È]H\ÈÜÝ]\ÛÝHÜÝ]KHÛÝ[[ÛÈY\ÈY[H^HÛÛÜ]H\\Ë[Y]HYK]IÛHÝÝ\HÝÈÈÈ]Ú]Ý]ØÜ]Ú[È\Ù\È\\B\H[ÛÈÛÛYHÛÛ\[K][YH\ÜÝY\ÈÚ]ÜXÚYZ[ÈÛÛÜ]H\\È[ÛÛYBØ\Ù\ËÜ^[\KØ^HHÜXÚYHHÛÛÜ]H\HÙHÙ]\ÈÜÙ][HÛÛÜ]H\HÙ[ÏO\ÈÚ[O[[ÝIÜH[ÝÙYÈÜ]BHÛÝÚ[È
Ü\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¡¥Ì½Í¸Ð½±±½Ü¡½ÝÙÈÑ¡ÕÉɹÐÑɹ½¬¬ÄܼÈÀ(ø
½¹ÁÑ̸(ø(øÑåÁ¥Ìµ½°½
½¹ÁХ̥С
Ì
¸áÁ±¥¥Ðµ
ÁÁ¥¹½¥ÑÌ(ø
Í6FVBÖær7G'V7GW&Rà£à£âFR6öç7FçB6öæ6WB6÷VÆBfRÖ6BFBFVfVÇG2FòFRæW7FV@£âÖVÖ&W'2ÂæB6òÖ¶RV6W"÷W"Öærà ¥÷Rw&R&vBÂwfR&VVâFæ¶ær&÷WBFBâF2&ö×G2ÖRFò÷VâF0¦77VR³%Òà £âv÷VÆB&VfW"bæW6VBFffW&VçBæÖRf÷"26öæ6WG2âà£âFFFöâæ6öæ6WG2fRâ76ö6FVB6Æ72Âv62²³ró#6öæ6WG0£â&R&VF6FW2à£âv÷VÆB&W6W'fRFR6ÖVÄ66Rf÷"2²²6öæ6WG2æBFRÆ÷vW&66Rf÷"FP£âÖær7G'V7BÀ£à£â7G'V7BÆ6FfR°£âFV×ÆFRÇGVæÖRà£â7G'V7BG&ç6f÷&Õö×ð£âÓ°£à£âFV×ÆFRÇGVæÖRcà£â6öæ6WB&ööÂÆ6FfRÒ&WV&W2âââã° ¤Fæ²Bv÷VÆB&R&WGFW"FòvBVçFÂvRö7GVÆÇòfR6öæ6WG2à§FRÆæwVvR&Vf÷&RG'ÈÈ[][]H[HÛÈ\H[È]\ÈÛÛÙ][HÙ\ÈÝ][È]HÛÛÙ\È
[HÛÛÙ\Ë[]HÙ[ÙJKÚ[ÈÝ\Ú\ÙHÛÝ[HZ\ÛXY[ËËBHÛÛÙ\ÈXZÙHÈY[[ÛÙZ[[][H\H\]Z\[Y[ÝXÚ\Â[ÝPÛÛÝXÝXKH[Y]HHYÚ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\ÙHY\È\È\ÜÝYHÍHÜÝ]\ËHÛÝÛÝËHÛÛÝZ[È]\ÝHÝ]YÚ\HYYY\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öbFRFöÖâà£âÖöæöB2G&ÆWB
BÂ÷ÂæWWG&ÂÂvW&R÷2&æ'÷W&Föà£âöâBæBæWWG&Â2FRæWWG&ÂVÆVÖVçBB&W7V7BFòF2÷W&Föâà£âvB2w&öærFVâvFÖöæöC£¦÷æBÖöæöC£¦æWWG&ÂÂç7FVBöbFP£âævÆö&Ç2ÇW2æB¦W&óòFöòfW&&÷6SòfærFW6RæÖW2öâ£âæÖW76RÆWBFRW6W"Ö¶RFR6ö6Rà ¤B&V6öÖW2w&öærvVâ÷RfRÖ÷&R6ö×ÆWGR6Æ76W2â÷rv÷VÆB÷P¦6ÆÂFR&ærw2÷W&FöâæBFVçFGòæB÷rv÷VÆB÷R6ÆÂFP¦÷W&Föç2öbÖöæCòWFæB×R2FRÖFVÖF6ç2FòCòæò§Fæ²vRfRFòWB7GVÂæÖW2B6öÖRöçBÂWfVâbFBÖVç0¦Æ÷6ær6öÖRvVæW&ÆGà £âv÷VÆBæ÷B&÷fFRç÷W&F÷'2f÷"FRÖöæöB6öæ6WBà ¤ÒFæ¶æXÝ]\ÜÛØÚX][ÈHÜ\]ÜÈÛHHÛÛÙ\ÈÜXÚXØ[X\ÛÛÎÈÙYHÌ×K[ÝXYÜ\]ÜÈÛÝ[H[YÜXXÚ]H\KYØ\[È\XXH[\]\È[ÑHÝYÚ\XXH[\]\ÈÛÝ[ÝXYÈÑ[Û][ÛÏÈHÛÝÈÛØ[[Ý[ÛØXÝÈ
][ÛÛÝ^HØ[XYÈÑ[Û][ÛË]HØ\ÛÝ]Ø\HXÝ]HØ[HÜ\XXB[\]\ËHÛÝ[\XÚX]HY[ÝHÛÝ[ÚÝÈYHÚ\HHØ[HY\Â[ÜHÜXÚYXØ[K[ÛËÜY\[ÙK\IÜÈHYXÝ\ÜÎWH[]YÈÛØ[ÛÛÝ^ØXÝË[[\ÜÝYHXÚÚ[È\ÈØ[H\HÌLK[[KYØ\[È^XÝ]XHØ]Ù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