On Monday, 22 May 2017 at 10:35:36 UTC, ag0aep6g wrote:
On 05/22/2017 10:58 AM, biocyberman wrote:
[...]

For reference, here is the version of revComp3 I commented on:

----
string revComp3(string bps) {
    const N = bps.length;
    enum chars = [Repeat!('A'-'\0', '\0'), 'T',
                Repeat!('C'-'A'-1, '\0'), 'G',
                Repeat!('G'-'C'-1, '\0'), 'C',
                Repeat!('T'-'G'-1, '\0'), 'A'];

[...]

Very illustrative. I could easily miss and I did miss this subtle but important aspect. I wonder how D should widen the 'pit of success' that Scott Meyers mentioned about more than once. A take home message for myself, if one ever use an array as a lookup table, make it 'static immutable. And enum array does not make sense'. And in Ali's book:

Consider the hidden cost of enum arrays and enum associative arrays. Define them as immutable variables if the arrays are large and they are used more than once in the program.

One thing also became clear: 'is' is not '=='. Therefore

writeln([10,20] is [10,20]); /* false */
writeln([10,20] == [10,20]); /* true */

I did not notice that because I haven't come across 'is' so often.

Reply via email to