www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: A scoping operator

reply J Anderson <REMOVEanderson badmama.com.au> writes:
Doesn't . refer to global scope?

Couldn't we just extend that?

. //Global scope
.. //Next scope under the global scope
//and so on

ie

int a; //global a

class A
{
 int a;

 void  A
 {
      .a; //refers to global a
      ..a; //refers to A.a
 }

}

and

: //Next most available scope that has the variable name (not including 
the current scope)
:: //Next most available scope that has the variable name (not including 
the current scope, or the next most outer scope)
//and so on

int a; //global a

class A
{
 static int a;

 struct X
 {
   int a;
   struct Y
   {
     void  A
     {
          a; //refers to A.X.a
          :a; //refers to A.X.a //If struct Y was removed it would refer 
to A.a
          ::a; //refers to A.a
          :::a; //refers to global a
       }
    }
 }
}

I guess the above could be changed to something like:

: //Next scope (not including the current scope)
:: //Next scope (not including the current scope, or the next most outer 
scope)
//and so on

Which could help prevent errors.


That way you can go both ways (from the global and from the local).

PS - Sorry for posting to your personal email.  Dam mozilla. - 3rd time 
lucky <g>

-- 
-Anderson: http://badmama.com.au/~anderson/
May 01 2004
parent reply "Scott Egan" <scotte tpg.com.aux> writes:
Is there actually such a thing as global scope?  From what I can tell the
highest level of scope is module.

Or is that what you mean?

I'm not trying to be smart, just want to be correct.

This thread is relevant to my 'Gripe about 'with'' thread.

Another reason to use '::' would be to free up '.' for use in 'with'.  Which
if nothing else improves readability because it is obvious where the
reference is comming from.  (I found the use of just the varible names in
the with block a bit uncomfortable).




"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c714f0$1guj$1 digitaldaemon.com...
 Doesn't . refer to global scope?

 Couldn't we just extend that?

 . //Global scope
 .. //Next scope under the global scope
 //and so on

 ie

 int a; //global a

 class A
 {
  int a;

  void  A
  {
       .a; //refers to global a
       ..a; //refers to A.a
  }

 }

 and

 : //Next most available scope that has the variable name (not including
 the current scope)
 :: //Next most available scope that has the variable name (not including
 the current scope, or the next most outer scope)
 //and so on

 int a; //global a

 class A
 {
  static int a;

  struct X
  {
    int a;
    struct Y
    {
      void  A
      {
           a; //refers to A.X.a
           :a; //refers to A.X.a //If struct Y was removed it would refer
 to A.a
           ::a; //refers to A.a
           :::a; //refers to global a
        }
     }
  }
 }

 I guess the above could be changed to something like:

 : //Next scope (not including the current scope)
 :: //Next scope (not including the current scope, or the next most outer
 scope)
 //and so on

 Which could help prevent errors.


 That way you can go both ways (from the global and from the local).

 PS - Sorry for posting to your personal email.  Dam mozilla. - 3rd time
 lucky <g>

 -- 
 -Anderson: http://badmama.com.au/~anderson/

May 01 2004
parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
Scott Egan wrote:

(I found the use of just the varible names in the with block a bit
uncomfortable).
  

-- -Anderson: http://badmama.com.au/~anderson/
May 01 2004
next sibling parent "Scott Egan" <scotte tpg.com.aux> writes:
Is that the same as too soft ;)


"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c71eva$228o$1 digitaldaemon.com...
 Scott Egan wrote:

(I found the use of just the varible names in the with block a bit



-- -Anderson: http://badmama.com.au/~anderson/

May 01 2004
prev sibling next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
J Anderson wrote:
 Scott Egan wrote:
 
 (I found the use of just the varible names in the with block a bit 
 uncomfortable).
  


Better too much VB than too much JScript. ;) -- Justin http://jcc_7.tripod.com/d/
May 01 2004
parent reply "Unknown W. Brackets" <unknown at.simplemachines.dot.org> writes:
J C Calvarese wrote:
 
 Better too much VB than too much JScript. ;)
 

Yes, JScript (being Microsoft's proprietary version of JavaScript) is perhaps a worse evil than Visual Basic or VBScript. Comparing Visual Basic and JavaScript is not fair, because they have not only totally different purposes but one is also compiled (mostly) and the other isn't. However, JavaScript compared to VBScript... is not a comparison. It is easy to see or prove that JavsScript is more often used, and much better supported. And, have you looked at this? http://www.digitalmars.com/dscript/ Looks like our good Walter prefers it too. (he didn't even mention VBScript on that page, did he?) I'm not surprised, because Visual Basic is... well, it's like making an RPG with RPG maker. It's not *really* making a game. But, these are just my opinions, and I have absolutely no intentions of arguing this point with you - especially because, frankly, there is not a single thing you could say to get me to say Visual Basic is a good programming language. -[Unknown]
May 01 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Unknown W. Brackets wrote:
 J C Calvarese wrote:
 
 Better too much VB than too much JScript. ;)

Yes, JScript (being Microsoft's proprietary version of JavaScript) is perhaps a worse evil than Visual Basic or VBScript. Comparing Visual Basic and JavaScript is not fair, because they have not only totally different purposes but one is also compiled (mostly) and the other isn't. However, JavaScript compared to VBScript... is not a comparison. It is easy to see or prove that JavsScript is more often used, and much better supported. And, have you looked at this? http://www.digitalmars.com/dscript/ Looks like our good Walter prefers it too. (he didn't even mention VBScript on that page, did he?) I'm not surprised, because Visual Basic is... well, it's like making an RPG with RPG maker. It's not *really* making a game. But, these are just my opinions, and I have absolutely no intentions of arguing this point with you - especially because, frankly, there is not a single thing you could say to get me to say Visual Basic is a good programming language. -[Unknown]

I've got no beef with ECMA script or JavaScript in particular. As far as Microsoft's proprietary languages, I prefer VBScript to JScript because I'm more confortable with BASIC syntax and it has a "for each". I guess seeing your mention of JavaScript in the "Gripes about 'with'" thread inspired me to make fun of its cousin JScript. -- Justin http://jcc_7.tripod.com/d/
May 02 2004
parent reply "Unknown W. Brackets" <unknown at.simplemachines.dot.org> writes:
J C Calvarese wrote:
 
 I've got no beef with ECMA script or JavaScript in particular. As far as 
 Microsoft's proprietary languages, I prefer VBScript to JScript because 
 I'm more confortable with BASIC syntax and it has a "for each".

JavaScript has: for (var key in array) alert(key + " -> " + array[key]); Which is essentially "for each". Works on associatives and arrays - which are essentially the same thing, mind you. -[Unknown]
May 02 2004
parent J C Calvarese <jcc7 cox.net> writes:
Unknown W. Brackets wrote:
 J C Calvarese wrote:
 
 I've got no beef with ECMA script or JavaScript in particular. As far 
 as Microsoft's proprietary languages, I prefer VBScript to JScript 
 because I'm more confortable with BASIC syntax and it has a "for each".

JavaScript has: for (var key in array) alert(key + " -> " + array[key]); Which is essentially "for each". Works on associatives and arrays - which are essentially the same thing, mind you. -[Unknown]

Thanks for the correction. -- Justin http://jcc_7.tripod.com/d/
May 02 2004
prev sibling parent reply "Phill" <phill pacific.net.au> writes:
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c71eva$228o$1 digitaldaemon.com...
 Scott Egan wrote:

(I found the use of just the varible names in the with block a bit




Or both? Phill
May 01 2004
parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
Phill wrote:

"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c71eva$228o$1 digitaldaemon.com...
  

Scott Egan wrote:

    

(I found the use of just the varible names in the with block a bit
      


      


Or both? Phill

Doesn't matter, they both make you look stupid. I apologise, I just couldn't resist. -- -Anderson: http://badmama.com.au/~anderson/
May 01 2004
next sibling parent "Scott Egan" <scotte tpg.com.aux> writes:
LOL to both of you



"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c71ts1$2qr7$1 digitaldaemon.com...
 Phill wrote:

"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c71eva$228o$1 digitaldaemon.com...


Scott Egan wrote:



(I found the use of just the varible names in the with block a bit




Or both? Phill

Doesn't matter, they both make you look stupid. I apologise, I just couldn't resist. -- -Anderson: http://badmama.com.au/~anderson/

May 02 2004
prev sibling parent "Phill" <phill pacific.net.au> writes:
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c71ts1$2qr7$1 digitaldaemon.com...
 Phill wrote:

"J Anderson" <REMOVEanderson badmama.com.au> wrote in message
news:c71eva$228o$1 digitaldaemon.com...


Scott Egan wrote:



(I found the use of just the varible names in the with block a bit




Or both? Phill

Doesn't matter, they both make you look stupid. I apologise, I just couldn't resist.

May 02 2004