Re: [Beanshell-users] RE: Announce: Upcoming BeanShell 1.3 Scoping Changes...

Pat <[email protected]>
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
On Thu, Jun 26, 2003 at 06:12:47AM +0900, Daniel Leuck wrote:
> > But the first change (looking for a previously defined variable in the parent 
> > scope first) would make the language equally unsuitable for large scripts
> > unless people changed their habits to scope their local variables... because
> > any new variable added in the global scope would change the meaning of that
> > variable name everywhere in the script...  
> 
> I would say this is an argument against using many global variables in large scripts, and, if you must, using a different capitalization or naming convention.  I wouldn't adjust the language to accommodate a poor programming practice.

Now I'm waffling.

I guess this isn't so bad:

	flag = false;

	setFlag() {
		flag = true;
		localVar = true;
	}

	setFlag();
	print( flag ); // true

I'm still afraid of people breaking scripts by adding variables at the top.
But the joy of having variables default to local scope may outweight that.

Let's see if anyone else chimes in in the next day or so while I update 
the manual with other stuff.

> Also, I advocate adding var to allow for syntactically perspicuous local declaration of untyped variables.  I suppose this is a separate discussion...

"var" has been added.


Pat


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.