Bartc wrote:
>
> "Chris Dollin" <> wrote in message
> news:fsd8ce$35o$...
>> Richard Heathfield wrote:
>>
>>> Chris Dollin said:
>>>
>>>> Sensei <Sensei's e-mail is at Mac-dot-com> wrote:
>>>>> I am thinking about the use of code blocks in order to help readability
>>>>> of code that make use of "modal" function calls. One example is OpenGL:
>>>>>
>>>>> glBegin(whatever);
>>>>> glFunction1(x);
>>>>> glFunction2(y);
>>>>> ...
>>>>> glEnd();
>>>>>
>>>>> which can be rewritten as
>>>>>
>>>>> glBegin(whatever);
>>>>> {
>>>>> glFunction1(x);
>>>>> glFunction2(y);
>>>>> ...
>>>>> }
>>>>> glEnd();
>>>>>
>
>>>>> Do you see anything bad about this convention?
>>>>
>>>> IMAO: it's pointless.
>>>
>>> Isn't that just a touch A, Chris? 
>>
>> As you noticed, Bob\\\Richard, I said so myself.
>>
>>> It may not be your cup of tea, but
>>> style is a very personal thing. I'm not saying I'd necessarily do it the
>>> way he is doing it, but I can certainly see where he's coming from.
>>
>> I see what he's trying to do: I just think that it doesn't
> ...
>>>> If I wanted to do something like that,
>>>> I'd abstract those two functions into another one with a
>>>> useful name.
>>>
>>> Can you demonstrate to the OP how you would do that?
>
>> Replace
>>
>> glFunction1(x);
>> glFunction2(y);
>>
>> with
>>
>> aProperNameForThisModalGroup();
>>
>> defining
>>
>> static void aPropertNameForThisModalGroup()
>> {
>> glFunction1(x);
>> glFunction2(y);
>> }
>
> You're overcomplicating what the OP is trying to achieve.
I (obviously) don't think so.
> if these were
> really opengl calls then typically it might look like:
>
> glBegin(whatever);
> {
> glVertex(x1,y1,z1);
> glVertex(x2,y2,z2);
> glVertex(x3,y3,z3);
> .....
> };
> glEnd();
Apart from the not-necessary-for-the-examples, that's essentially what
the OP had, so we already knew this.
> The glBegin/glEnd calls are bracketing the data calls inbetween, but they
> belong as one unit.
Hence my suggestion, in the very same post, that the bracketing be
abstracted into a function.
> The {,} are unnecessary; just tabs are sufficient. Or BEGIN/END macros that
> do nothing.
I think both of those suggestions are /worse/ than just using {}.
[I am assuming, by the way, that the clutterbraces aren't part of
a common OpenGL style which the OP is trying to follow. If that's
what the culture expects, then that's what the OP should use, and
argue about it to taste.]
> Creating extra functions is just extra clutter.
Not when the functions can be given meaningful names, or passed as
parameters to other functions.
> Unless there are lots of
> calls between glBegin/glEnd but then the whole group including glBegin/glEnd
> would go into the function, and inside that function the glVertex/whatever
> calls will be indented.
If one uses the `executeModalGroup` trick, one only has to group the
modal calls, because the modal begin-end has been encapsulated.
--
"The situation, it appeared, was in hand." /Excession/
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN