On 27/08/15 09:27, Tom Hacohen wrote:
> On 27/08/15 01:32, Carsten Haitzler wrote:
>> On Wed, 26 Aug 2015 10:15:31 +0100 Tom Hacohen <[email protected]> said:
>>
>>> Good fix. The fact that we even allow if/else statements without {} in
>>> anywhere except for quick error checking at beginning of functions is
>>> blasphemy. Furthermore, allowing them nested and without curlys, is even
>>> worse.
>>
>> indeed. no {} i'f like:
>>
>> if (x)
>> return x;
>>
>> if (y) z = 10;
>>
>> if (x) do_y();
>> else x = 10;
>>
>> etc.
>>
>> are all we should allow - this should be the limit. if you have complex
>> nested
>> things like
>>
>> if (x)
>> if (y)
>> return x;
>> else
>> return y;
>>
>> really shouldn't happen. it creates the problem where indenting indicates
>> which
>> if and else if together... always use {}'s for anything other than the really
>> simple cases above. it's the same logic of using ()'s in logic and math.
>>
>> the same applies for nested for loops and while loops too.
>>
>> if (((a < 10) && (b < 20)) || (c == 3)) ...
>>
>> is far better than
>>
>> if (a < 10 && b < 20 || c == 3)
>>
>> the first is explicit in what i wanted... the second... who knows what was
>> INTENDED...
>>
>> same for math.
>>
>> y = 10 + x / 4 * 17 ^ 0x24f
>>
>> is bad.
>>
>> y = (((10 + x) / 4) * 17) ^ 0x24f
>>
>> is good. if you see code, patches that doesn't have anything other than
>> TRIVIAL
>> operations where it is blatantly obvious what the case is - insist on ()'s or
>> {}'s to clarify the intent and avoid problems.
>
> While I can tolerate
> if (x) do_y();
> else x = 10;
>
> in some cases, I can't tolerate:
Just to clarify: I can sometimes tolerate the one above, but never the
one below.
>
> if (x) do_y();
> else
> {
> x = 10;
> }
>
> I find this horrible and confusing.
>
> I personally dislike not having {}.
>
>>
>>> --
>>> Tom.
>>>
>>> On 26/08/15 10:10, Amitesh Singh wrote:
>>>> ami pushed a commit to branch master.
>>>>
>>>> http://git.enlightenment.org/core/elementary.git/commit/?id=a7108c9b5ac1dd8432dc814785dd12f5ff8528de
>>>>
>>>> commit a7108c9b5ac1dd8432dc814785dd12f5ff8528de
>>>> Author: Amitesh Singh <[email protected]>
>>>> Date: Wed Aug 26 14:34:58 2015 +0530
>>>>
>>>> gengrid: add curly braces to avoid ambiguous 'if'
>>>> ---
>>>> src/lib/elm_gengrid.c | 20 ++++++++++++--------
>>>> 1 file changed, 12 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
>>>> index 4d47952..e734399 100644
>>>> --- a/src/lib/elm_gengrid.c
>>>> +++ b/src/lib/elm_gengrid.c
>>>> @@ -2445,10 +2445,12 @@ _elm_gengrid_item_edge_check(Elm_Object_Item
>>>> *eo_it,
>>>> if ((sd->horizontal) && (ix == cx) && (iy > cy))
>>>> return EINA_FALSE;
>>>> else if ((!sd->horizontal) && (iy == cy))
>>>> - if ((!mirrored && (ix >cx)) || (mirrored && (ix < cx)))
>>>> - return EINA_FALSE;
>>>> - else
>>>> - return EINA_TRUE;
>>>> + {
>>>> + if ((!mirrored && (ix > cx)) || (mirrored && (ix < cx)))
>>>> + return EINA_FALSE;
>>>> + else
>>>> + return EINA_TRUE;
>>>> + }
>>>> else
>>>> return EINA_TRUE;
>>>> }
>>>> @@ -2471,10 +2473,12 @@ _elm_gengrid_item_edge_check(Elm_Object_Item
>>>> *eo_it,
>>>> if ((sd->horizontal) && (ix == cx) && (iy < cy))
>>>> return EINA_FALSE;
>>>> else if ((!sd->horizontal) && (iy == cy))
>>>> - if ((!mirrored && (ix < cx)) || (mirrored && (ix > cx)))
>>>> - return EINA_FALSE;
>>>> - else
>>>> - return EINA_TRUE;
>>>> + {
>>>> + if ((!mirrored && (ix < cx)) || (mirrored && (ix > cx)))
>>>> + return EINA_FALSE;
>>>> + else
>>>> + return EINA_TRUE;
>>>> + }
>>>> else
>>>> return EINA_TRUE;
>>>> }
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> enlightenment-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> enlightenment-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel