Metaprog can be abstruse

user1234 user1234 at 12.de
Mon Jul 4 14:09:21 UTC 2022


On Monday, 4 July 2022 at 13:03:55 UTC, Dom Disc wrote:
> On Monday, 4 July 2022 at 10:19:36 UTC, Bastiaan Veelo wrote:
>> On Monday, 4 July 2022 at 09:43:11 UTC, user1234 wrote:
>>> On Monday, 4 July 2022 at 09:40:45 UTC, Bastiaan Veelo wrote:
>>>> Not necessarily.
>>>> ```d
>>>> immutable decimalRanks = iota(10).map!(p => 10.pow(p)).array;
>>>> ```
>>> Hi, to this alternative I'd say that it's not self 
>>> documenting.
>>> So it still has 50% of the initial problem.
>> There is a point to be made that this is more self-documenting 
>> than the hand-written alternative: Here it is obvious that the 
>> ranks cover all powers of 10 from 0 to 9 in order.
>
> This advantage becomes much more clear in, let's say:
> ```d
> immutable long powersOfThree = iota(27).map!(p => 
> 3.pow(p)).array;
> ```
> Handwritten this is a very long chain of arbitrary numbers and 
> you have to put a very close look, that those are indeed the 
> powers of three.

another blind man.


More information about the Digitalmars-d mailing list