Case Range Statement ..

Lutger lutger.blijdestijn at gmail.com
Sat Jul 11 10:55:35 PDT 2009


Daniel Keep wrote:

> 
> Valery wrote:
>> I think that inclusive ranges more intuitive for beginner programmers
>> because statements:
>> 
>>   case 1..10,
>>   array [1..10],
>>   foreach (int item; 1..10),
>>   foreach_reverse (int item; 1..10) (now foreach_reverse range is too
>>   dificult to understand it: item begins with 10 or 9, ends 1 or 2?)
>> 
>> will not require an explanation of their actions. Thanks.
> 
> I can say from personal experience that this is true.
> 
> 1-based indexing is also easier for beginners.
> 
> So are BASIC and LOGO.
> 
> You may notice a trend here... :P
> 
> Inclusive ranges are easier for naive programmers to grok, but are
> fundamentally mismatched to programming.  It's harder to split an
> inclusive range, and it complicates the math.  Just try writing anything
> which involves manipulating ranges in Lua; it's considerably harder than
> with exclusive ranges.
> 
> The question is which you would rather: help naive programmers work
> inefficiently or prevent competent programmers from working efficiently?
> 
> I say screw the beginners; learning will do them good.

Besides, when learning programming the concept of zero-based indexing and 
exclusive ranges is amongst the most trivial of concerns you need worry 
about these days.




More information about the Digitalmars-d mailing list