On Sunday, 25 January 2015 at 13:03:16 UTC, bearophile wrote:
Dominikus Dittes Scherkl:

Because this is useful in more situations,

Right, but it's still a cast. And in D you want to minimize the number of usages of casts. The proposed syntax iota!"[]" is cast-safe.

I don't case too much, if I have ensured the cast is safe by constraints beforehand.

I need to cast often anyway, because I work with small types and most operators permanently change everything to "int", especially the bit-operations for which a signed type makes no sense at all:

ubyte x = 50;
auto y = x & 0x11; // y is int! I hate that!

even if I use unsigned literals:
auto z = x & 0x12u; // z is uint - better but still bad. More so as & should result in the smaller of the two types!!

But I need not even use literals (which unfortunately cannot be makred as "ubyte" or "short"). Look at this:

auto x2 = (x>>4) | (x<<4); // swap nibbles - but result in an int!!!!!
    • Re: using the full r... Dominikus Dittes Scherkl via Digitalmars-d-learn
      • Re: using the fu... ketmar via Digitalmars-d-learn
        • Re: using th... Dominikus Dittes Scherkl via Digitalmars-d-learn
          • Re: usin... ketmar via Digitalmars-d-learn
            • Re:... Vlad Levenfeld via Digitalmars-d-learn
              • ... bearophile via Digitalmars-d-learn
              • ... Dominikus Dittes Scherkl via Digitalmars-d-learn
              • ... Tobias Pankrath via Digitalmars-d-learn
              • ... Dominikus Dittes Scherkl via Digitalmars-d-learn
              • ... bearophile via Digitalmars-d-learn
              • ... Dominikus Dittes Scherkl via Digitalmars-d-learn
              • ... ketmar via Digitalmars-d-learn
              • ... Dominikus Dittes Scherkl via Digitalmars-d-learn
              • ... ketmar via Digitalmars-d-learn
  • Re: using the full range ... ketmar via Digitalmars-d-learn
  • Re: using the full range ... ketmar via Digitalmars-d-learn

Reply via email to