Home All Groups Group Topic Archive Search About
Author
20 Nov 2007 9:46 AM
guy
I do not usually use the colon in my code however sometimes i find it usefull
e.g.

pulling data from an array

....
i += 1 : this = stuff(i)
i += 1 : that = stuff(i)
i += 1 : theOther = stuff(i)
....

as it reads more clearly than incrementing i on a separate line.
Is this considered bad practice?

guy

Author
20 Nov 2007 12:05 PM
Armin Zingler
Show quote Hide quote
"guy" <g**@discussions.microsoft.com> schrieb
> I do not usually use the colon in my code however sometimes i find
> it usefull e.g.
>
> pulling data from an array
>
> ...
> i += 1 : this = stuff(i)
> i += 1 : that = stuff(i)
> i += 1 : theOther = stuff(i)
> ...
>
> as it reads more clearly than incrementing i on a separate line.
> Is this considered bad practice?

I did it many years ago, then considered it bad practice for many years, now
I start considering it a legitimate way (in some cases like your example)

So: A matter of taste.


Armin
Author
20 Nov 2007 12:31 PM
Phill W.
guy wrote:

> I do not usually use the colon in my code 

.... likewise ...

> however sometimes i find it useful, e.g.  pulling data from an array

> ...
> i += 1 : this = stuff(i)
> i += 1 : that = stuff(i)
> i += 1 : theOther = stuff(i)
> ...

Personally, unless both of these arrays are dynamic and the index ranges
all over the place, I'd just /hard-code/ the offsets:

    Const XOffset as Integer = 0
    Const YOffset as Integer = 1
    Const ZOffset as Integer = 2

    this = stuff( i + XOffset )
    that = stuff( i + YOffset )
    theOther = stuff( i + ZOffset )

> as it reads more clearly than incrementing i on a separate line.

Agreed.

> Is this considered bad practice?

It certainly /used/ to be (I'm thinking VB6 here) because it was darned
difficult to put breakpoints on the second and subsequent statements on
a given line.
I don't think it's a problem any more, so whatever works for you...

HTH,
    Phill  W.


Show quoteHide quote
>
> guy