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

"Daniel Leuck" <[email protected]>
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <001d01c33b5e$8ace5b10$eefcc3db@sabrina>
> 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.

> To use the new style of scoping people would have to change their habits
> and make their local variables local by either declaring them with var or 
> prefixing them (at least the first time) with 'this.'.

Why?  Auto-assignments could default to local scope if they are undeclared in a parent scope.

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

-----Original Message-----
From: beanshell-developers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org [mailto:beanshell-developers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of Pat
Sent: Thursday, June 26, 2003 5:48 AM
To: Daniel Leuck; 'Shankar Unni'; beanshell-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [Beanshell-users] RE: [Beanshell-dev] Announce: Upcoming BeanShell 1.3 Scoping Changes...

On Thu, Jun 26, 2003 at 05:31:26AM +0900, Daniel Leuck wrote:
> > In BeanShell 1.3 the assignments
> > now follow the "strict Java" style of applying wherever the 
> > variable was defined, or ultimately in the global scope if 
> > not defined at all.  
> 
> I think the first part is great, the second part, as Shankar pointed out, is problematic.
> 
> I really think making auto-declared variables global will cause massive pollution of the namespace, introduce bizarre and hard to track bugs, and cause beanshell to be unsuitable for large scripts.

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...  that was my foremost worry 
initially.

To use the new style of scoping people would have to change their habits
and make their local variables local by either declaring them with var or 
prefixing them (at least the first time) with 'this.'.

Again, I don't like this either, but it seems like the healthiest thing
to do at this point...  Still open to suggestions.


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
_______________________________________________
Beanshell-developers mailing list
Beanshell-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/beanshell-developers



-------------------------------------------------------
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.