Ecere SDK/eC Forums • View topic - Variable declaration at begining of code block




Ecere SDK/eC Forums

Ecere Developers Community

Variable declaration at begining of code block

General help with the eC language.

Variable declaration at begining of code block

Postby redj » Wed Feb 09, 2011 11:28 am

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

-redj
redj
 
Posts: 107
Joined: Sun Jan 17, 2010 10:03 am

Re: Variable declaration at begining of code block

Postby jerome » Wed Feb 09, 2011 2:09 pm

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.
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: Variable declaration at begining of code block

Postby jfbilodeau » Wed Feb 09, 2011 2:11 pm

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

I suspect is an Ecere thing and not a gcc -c89 thing, right?
jfbilodeau
 
Posts: 19
Joined: Wed Feb 09, 2011 11:47 am

Re: Variable declaration at begining of code block

Postby jerome » Wed Feb 09, 2011 2:46 pm

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
jerome
Site Admin
 
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm


Return to eC Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron