"with" still sucks + removing features + adding features

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon May 18 16:06:10 PDT 2009


bearophile wrote:
> Bill Baxter:
>> Agreed.  If you tell someone   a .. b  means a non-inclusive range
>> from a to b, then ask them to guess what    blarf a .. blarf b  means,
>> I would be very surprised if many guessed "inclusive range from blarf
>> a  to blarf b".
> 
> Thank you for nicely expressing one of the critics I was trying to express.
> (My other problem is that I'd like a more general syntax).
> 
> ------------------------
> 
> A different simple solution can be:
> case a .. b+1:
> That requires no new syntax.
> 
> Bye,
> bearophile

void classify(char c) {
    write("You passed ");
    switch (c) {
       case '#':
          writeln("a hash sign.");
          break;
       case '0' .. case '9':
          writeln("a digit.");
          break;
       case 'A' .. case 'Z': case 'a' .. case 'z':
          writeln("an ASCII character.");
          break;
       case '.', ',', ':', ';', '!', '?':
          writeln("a punctuation mark.");
          break;
       default:
          writeln("quite a character!");
          break;
    }
}

Cool!

void classify(char c) {
    write("You passed ");
    switch (c) {
       case '#':
          writeln("a hash sign.");
          break;
       case '0' .. '9'+1:
          writeln("a digit.");
          break;
       case 'A' .. 'Z'+1: case 'a' .. 'z'+1:
          writeln("an ASCII character.");
          break;
       case '.', ',', ':', ';', '!', '?':
          writeln("a punctuation mark.");
          break;
       default:
          writeln("quite a character!");
          break;
    }
}

Awful!


Andrei




More information about the Digitalmars-d mailing list