lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Oct 10, 2016 at 11:06 PM, Rena <hyperhacker@gmail.com> wrote:
> On Mon, Oct 10, 2016 at 3:52 PM, Igor Ehrlich <iehrlich@iponweb.net> wrote:
>>
>> >And, overuse of brackets...
>> At this point I got really curious. Could you please be more precise?
>>
>
> I guess technically you don't need the brackets in statements like:
>
> if (depth == 0) {
> luasdorintf("%-5i | ", stackIndex);
> } else {
> luasdorintf("       ", stackIndex);
> }
>
> It could be written like:
>
> if (depth == 0)
> luasdorintf("%-5i | ", stackIndex);
> else
> luasdorintf("       ", stackIndex);
>
> but IMO this is a stylistic choice, and I usually prefer the former, as it
> prevents mistakes like:
>
>
> if (depth == 0)
> luasdorintf("%-5i | ", stackIndex);
> else
> luasdorintf("       ", stackIndex);
> do_another_thing(); //oops, not conditional
>
> Anyway, bikeshedding aside, it's been pointed out on this list before that
> "public domain" isn't legally recognized in some parts of the world, and
> you're better to use something like the MIT License (that Lua uses itself)
> which gives the same effect without any potential hassle for those who want
> to use it.
>
> --
> Sent from my Game Boy.

+1 for not omitting { and } in one-line if and else.

-- 


Best regards,
Boris Nagaev