Variable declaration at begining of code block

General help with the eC language.
Post Reply
redj
Posts: 105
Joined: Sun Jan 17, 2010 10:03 am

Variable declaration at begining of code block

Post by redj »

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

-redj
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Variable declaration at begining of code block

Post by jerome »

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.
jfbilodeau
Posts: 19
Joined: Wed Feb 09, 2011 11:47 am

Re: Variable declaration at begining of code block

Post by jfbilodeau »

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

I suspect is an Ecere thing and not a gcc -c89 thing, right?
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Variable declaration at begining of code block

Post by jerome »

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
Post Reply