Ecere SDK/eC Forums
http://ec-lang.org/community/
Print view

Variable declaration at begining of code block
http://ec-lang.org/community/viewtopic.php?f=1&t=124
Page 1 of 1
Author:  redj [ Wed Feb 09, 2011 11:28 am ]
Post subject:  Variable declaration at begining of code block

Question from JF:
Are you obliged to declare your variable at the start of a block?

-redj
Author:  jerome [ Wed Feb 09, 2011 2:09 pm ]
Post subject:  Re: Variable declaration at begining of code block

Yes you are, just like in C89.

I prefer the grouping at the top, as you can quickly visualize which variables are available within the scope of that block.

We however need to relax the grammar to support variables being declared further on, and issue warnings instead of cryptic syntax errors. We should also have an option to relax that option for people who really want to do that.
Author:  jfbilodeau [ Wed Feb 09, 2011 2:11 pm ]
Post subject:  Re: Variable declaration at begining of code block

I'm one of those that really want to do that ;).

I suspect is an Ecere thing and not a gcc -c89 thing, right?
Author:  jerome [ Wed Feb 09, 2011 2:46 pm ]
Post subject:  Re: Variable declaration at begining of code block

It's an Ecere thing, though if you passed -c89 to GCC ( if there is such a thing I'm not sure ) it will bark at you for sure as well.

But do try to appreciate the beauty of well grouped variables at the top of your block ;)
You can always start a new compound block inside as well. It helps you organize sections of code around the variables that are used! :P
All times are UTC-05:00 Page 1 of 1