request switch statement with common block
Andre Artus
andre.artus at gmail.com
Mon Aug 5 10:51:17 PDT 2013
On Monday, 5 August 2013 at 09:37:11 UTC, dennis luehring wrote:
> Am 05.08.2013 08:28, schrieb luminousone:
>> or perhaps
>>
>> for( int i = 0 ; i < 10 ; i ++ )
>> in {
>> assert( i == 0 );
>> }
>> out {
>> assert( i == 9 );
>> }
>> body {
>> ... stuff ...
>> }
>
> that is just evil code
>
> if you got something todo before or on the first item of the
> list do it before the loop - and for the last behind the for
> loop
>
> if we talk about code-duplication then - use an inner function
>
> this type of sub-branching "de-looping" is slow (if performance
> is relevant) and just not foreach-able, and so not
> functional-style programming - its called "for loop index micro
> management for unknown reasons" - but many programmers prefer
> it very much :)
I have been programming since '92 and I must say that I have
never seen this before. Maybe I've just been lucky, but this kind
of thing would never pass a review anywhere I have worked before.
Code is a user interface, if the user's model differs from the
system model you will get errors. I.e. Junior von Newhire should
be able to correctly reason about any piece of the code from day
one. If they cannot do so they will introduce bugs.
More information about the Digitalmars-d
mailing list