digitalmars.D - A scoping operator
- Matthew (9/9) May 01 2004 One of the things I've wanted in C++ for a long time is the ability to b...
- Roel Mathys (6/21) May 01 2004 I think ':' and "::" are not used for the moment in D,
- J Anderson (53/53) May 01 2004 Doesn't . refer to global scope?
- Scott Egan (11/64) May 01 2004 Is there actually such a thing as global scope? From what I can tell th...
- J Anderson (4/6) May 01 2004 You've had to much VB.
- Scott Egan (4/11) May 01 2004 Is that the same as too soft ;)
- J C Calvarese (5/13) May 01 2004 Better too much VB than too much JScript. ;)
- Unknown W. Brackets (19/22) May 01 2004 Yes, JScript (being Microsoft's proprietary version of JavaScript) is
- J C Calvarese (9/40) May 02 2004 I've got no beef with ECMA script or JavaScript in particular. As far as...
- Unknown W. Brackets (7/11) May 02 2004 JavaScript has:
- J C Calvarese (5/22) May 02 2004 Thanks for the correction.
- Phill (6/11) May 01 2004 uncomfortable).
- J Anderson (5/26) May 01 2004 Doesn't matter, they both make you look stupid. I apologise, I just
- Scott Egan (3/33) May 02 2004 LOL to both of you
- Phill (3/31) May 02 2004 true true :o))
- Andy Friesen (6/18) May 01 2004 I'm not sure I see a need for this. There should only ever be three
- Phill (15/24) May 01 2004 able to
- J Anderson (6/17) May 01 2004 I had some students in a VB graphics programming class I'm tutoring. It...
- Jeroen van Bemmel (10/39) May 02 2004 I agree, this feature would encourage bad coding practices. Recommendati...
One of the things I've wanted in C++ for a long time is the ability to be able to use scope in a similar vein to file-system location. In other words, I would like to be able to have the following ::X - refers to X in global scope :X - refers to X in local scope ::::X - refers to X in next most local scope (only with better thought-out syntax) What I'm interested in are people's thoughts for whether this would be nice in D, and suggestions for syntax.
May 01 2004
Matthew wrote:One of the things I've wanted in C++ for a long time is the ability to be able to use scope in a similar vein to file-system location. In other words, I would like to be able to have the following ::X - refers to X in global scope :X - refers to X in local scope ::::X - refers to X in next most local scope (only with better thought-out syntax) What I'm interested in are people's thoughts for whether this would be nice in D, and suggestions for syntax.I think ':' and "::" are not used for the moment in D, maybe there are other uses for these? e.g. slicing ;-) bye roel
May 01 2004
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
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
Scott Egan wrote:(I found the use of just the varible names in the with block a bit uncomfortable).You've had to much VB. -- -Anderson: http://badmama.com.au/~anderson/
May 01 2004
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:uncomfortable).(I found the use of just the varible names in the with block a bitYou've had to much VB. -- -Anderson: http://badmama.com.au/~anderson/
May 01 2004
J Anderson wrote:Scott Egan wrote:Better too much VB than too much JScript. ;) -- Justin http://jcc_7.tripod.com/d/(I found the use of just the varible names in the with block a bit uncomfortable).You've had to much VB.
May 01 2004
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
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". 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/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 02 2004
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
Unknown W. Brackets wrote:J C Calvarese wrote:Thanks for the correction. -- Justin http://jcc_7.tripod.com/d/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
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:c71eva$228o$1 digitaldaemon.com...Scott Egan wrote:uncomfortable).(I found the use of just the varible names in the with block a bitIs that Victorian Bitter? or Visual Basic? Or both? PhillYou've had to much VB.
May 01 2004
Phill wrote:"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:c71eva$228o$1 digitaldaemon.com...Doesn't matter, they both make you look stupid. I apologise, I just couldn't resist. -- -Anderson: http://badmama.com.au/~anderson/Scott Egan wrote:uncomfortable).(I found the use of just the varible names in the with block a bitIs that Victorian Bitter? or Visual Basic? Or both? PhillYou've had to much VB.
May 01 2004
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...Doesn't matter, they both make you look stupid. I apologise, I just couldn't resist. -- -Anderson: http://badmama.com.au/~anderson/Scott Egan wrote:uncomfortable).(I found the use of just the varible names in the with block a bitIs that Victorian Bitter? or Visual Basic? Or both? PhillYou've had to much VB.
May 02 2004
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:c71ts1$2qr7$1 digitaldaemon.com...Phill wrote:true true :o))"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:c71eva$228o$1 digitaldaemon.com...Doesn't matter, they both make you look stupid. I apologise, I just couldn't resist.Scott Egan wrote:uncomfortable).(I found the use of just the varible names in the with block a bitIs that Victorian Bitter? or Visual Basic? Or both? PhillYou've had to much VB.
May 02 2004
Matthew wrote:One of the things I've wanted in C++ for a long time is the ability to be able to use scope in a similar vein to file-system location. In other words, I would like to be able to have the following ::X - refers to X in global scope :X - refers to X in local scope ::::X - refers to X in next most local scope (only with better thought-out syntax) What I'm interested in are people's thoughts for whether this would be nice in D, and suggestions for syntax.I'm not sure I see a need for this. There should only ever be three scopes: module, class, and local, all of which can be accessed via distinct syntax. Further, D forbids locals from shadowing 'outer' locals in nested scopes. -- andy
May 01 2004
"Matthew" <matthew.hat stlsoft.dot.org> wrote in message news:c70phi$112a$1 digitaldaemon.com...One of the things I've wanted in C++ for a long time is the ability to beable touse scope in a similar vein to file-system location. In other words, Iwould liketo be able to have the following ::X - refers to X in global scope :X - refers to X in local scope ::::X - refers to X in next most local scope (only with better thought-out syntax) What I'm interested in are people's thoughts for whether this would benice in D,and suggestions for syntax.This would be a good idea for people that would use it no doubt. But I can say that I wouldnt use it. Reason: For me it is much faster and clearer to choose another name for the variable, and know which one I am reffering to, than to sit there and work out which "X" I am reffering to each time I look at the method or block of code. But as I said, this is for my case. Phill.
May 01 2004
Phill wrote:This would be a good idea for people that would use it no doubt. But I can say that I wouldnt use it. Reason: For me it is much faster and clearer to choose another name for the variable, and know which one I am reffering to, than to sit there and work out which "X" I am reffering to each time I look at the method or block of code. But as I said, this is for my case. Phill.I had some students in a VB graphics programming class I'm tutoring. It took me ages to convince them that the dot meant a different variable. In the end I just renamed it. -- -Anderson: http://badmama.com.au/~anderson/
May 01 2004
"Phill" <phill pacific.net.au> wrote in message news:c71std$2oug$1 digitaldaemon.com..."Matthew" <matthew.hat stlsoft.dot.org> wrote in message news:c70phi$112a$1 digitaldaemon.com...I agree, this feature would encourage bad coding practices. Recommendation should be to use distinct names for variables as a rule, only in the most trivial and obviously non-conflicting (lazy programmer's) case should it be reluctantly endoursed. Perhaps the compiler should even emit warnings when variable names hide other variables in outer scopes. It should be able to work in a mode where this practice causes the program not to compile, such that companies can enforce it as a quality standard (I am thinking of a compiler switch here)One of the things I've wanted in C++ for a long time is the ability to beable touse scope in a similar vein to file-system location. In other words, Iwould liketo be able to have the following ::X - refers to X in global scope :X - refers to X in local scope ::::X - refers to X in next most local scope (only with better thought-out syntax) What I'm interested in are people's thoughts for whether this would benice in D,and suggestions for syntax.This would be a good idea for people that would use it no doubt. But I can say that I wouldnt use it. Reason: For me it is much faster and clearer to choose another name for the variable, and know which one I am reffering to, than to sit there and work out which "X" I am reffering to each time I look at the method or block of code. But as I said, this is for my case. Phill.
May 02 2004