Re: Initializing variables on declarations

new topic     » goto parent     » topic index » view thread      » older message » newer message

Robert Craig wrote:
> 
> 
> Here's what I said about this (and some other stuff) back in 2002:
> 
>   <a
>   href="http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=2&fromYear=7&toMonth=2&toYear=7&postedBy=rds&keywords=declaration+initialize">http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=2&fromYear=7&toMonth=2&toYear=7&postedBy=rds&keywords=declaration+initialize</a>
> 
> If a clear majority wants this, 

This is certainly not the case, it seems.  As I read it, it's about 50%, 
myself included.

> and someone is prepared to do it,

That's why I brought it up.

> I would go along with it (though I still don't think it's
> a particularly good idea.) However if you do it for global 
> (and local to a file) declarations, why not privates (inside a routine) 
> as well?

I would have, if this mod had enough support to actually do.
I just overlooked that part in my first glance.

> The only visual difference
> between a constant declaration and a variable declaration, is
> that people have to remind themselves that "constant" is not a type,
> it's something totally different.

Just about every editor used for Euphoria programming has keyword coloring
where constant and integers are different colors.  The doubled symbol
name on a typed line is just as easy to overlook as the single symbol
name being proposed.  This is one reason a lot of programmers capitalize
constants (or use a variation of Hungarian notation) and leave variables
in mixed case.

> I once spent hours debugging something in another language,
> simply because the author of the code had hidden a variable
> declaration with initialization in amongst 20 or so other declarations.
> I just couldn't "see" that the subroutine did not really "start" where 
> I thought it did. It actually started in the middle of the declarations
> somewhere.

In this "other language" (C perhaps?), you use braces for statements,
routines, structures, and I'm sure there are a few other places I'm 
forgetting at the moment.  Euphoria separates its parts with words, not
punctuation, so you have to try really hard to obfuscate the start of a
routine.  Don't forget that the constant assignment IS executing code
anytime there isn't a literal.  If I later try to assign a value to a 
constant, Euphoria will throw a very clear error (unlike those obscure
C errors that sometimes don't even point you to the right file, much less
the right line).

That's the last I'll say on this topic.  Unless there's a pretty big change
of support, this mod won't be getting done anytime soon.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu