D - readonly variables
- imr1984 (9/9) Feb 15 2004 ok so currently when people want a class member variable they dont want ...
- J Anderson (7/17) Feb 15 2004 I suggest the terms in and out.
-
Ben Hinkle
(25/25)
Feb 15 2004
"imr1984"
wrote in message news:c0nvjl$179... - J Anderson (10/36) Feb 15 2004 What about
- Matthew (11/52) Feb 15 2004 news:c0nvjl$1794$1@digitaldaemon.com...
- J Anderson (5/22) Feb 15 2004 I guess your talking about the scope here. Yeah, parhaps scope should
- Matthew (5/30) Feb 15 2004 Nah! I was just being a witless smartarse. My point was that it's so eas...
- imr1984 (5/30) Feb 15 2004 yeah something like that. all im saying is that the current method of cr...
- Matthew (18/62) Feb 15 2004 I don't look at underscores and see Hungarian. Sorry
- Manfred Nowak (15/20) Feb 15 2004 You like creating isles?
ok so currently when people want a class member variable they dont want anyone to mess with, they create the variable with a preceeding underscore and then create a read only property for it. So most of the time properties are unnesesary and a simple readonly variable would do. something like this: readonly int myVariable; instead of: private int _myVariable; int myVariable() {return _myVariable;} i hope walter considers this, because it would save time
Feb 15 2004
imr1984 wrote:ok so currently when people want a class member variable they dont want anyone to mess with, they create the variable with a preceeding underscore and then create a read only property for it. So most of the time properties are unnesesary and a simple readonly variable would do. something like this: readonly int myVariable; instead of: private int _myVariable; int myVariable() {return _myVariable;} i hope walter considers this, because it would save timeI suggest the terms in and out. out int myVariable; //Readonly in int myVariable2; //Writeonly inout int myVariable2; //Default -- -Anderson: http://badmama.com.au/~anderson/
Feb 15 2004
"imr1984" <imr1984_member pathlink.com> wrote in message news:c0nvjl$1794$1 digitaldaemon.com... | ok so currently when people want a class member variable they dont want anyone | to mess with, they create the variable with a preceeding underscore and then | create a read only property for it. So most of the time properties are | unnesesary and a simple readonly variable would do. something like this: | | readonly int myVariable; | | instead of: | | private int _myVariable; | int myVariable() {return _myVariable;} | | i hope walter considers this, because it would save time What about other the protection attributes? The meaning of a "readonly" attribute overlaps with the protection attribute. What does something like readonly public int myVariable; declare? Or, similarly, what about readonly private int myVariable; Any attribute that controls read/write access needs to spell out how it interacts with the protection attributes. Perhaps some fancy protection attribute syntax would be better than a separate attribute - not that I can think of any good suggestions. -Ben
Feb 15 2004
Ben Hinkle wrote:"imr1984" <imr1984_member pathlink.com> wrote in message news:c0nvjl$1794$1 digitaldaemon.com... | ok so currently when people want a class member variable they dont want anyone | to mess with, they create the variable with a preceeding underscore and then | create a read only property for it. So most of the time properties are | unnesesary and a simple readonly variable would do. something like this: | | readonly int myVariable; | | instead of: | | private int _myVariable; | int myVariable() {return _myVariable;} | | i hope walter considers this, because it would save time What about other the protection attributes? The meaning of a "readonly" attribute overlaps with the protection attribute. What does something like readonly public int myVariable; declare? Or, similarly, what about readonly private int myVariable; Any attribute that controls read/write access needs to spell out how it interacts with the protection attributes. Perhaps some fancy protection attribute syntax would be better than a separate attribute - not that I can think of any good suggestions. -BenWhat about int myVariable {return myVariable;} Where myVariable is created implicitly. This code would be executed inside and outside the class for myVariable however the variable would only be changeable from within the class. It wouldn't completely solve the private situation but at least the code is still used in private situations. -- -Anderson: http://badmama.com.au/~anderson/
Feb 15 2004
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:c0oh8p$22ea$1 digitaldaemon.com...Ben Hinkle wrote:news:c0nvjl$1794$1 digitaldaemon.com..."imr1984" <imr1984_member pathlink.com> wrote in messageanyone| ok so currently when people want a class member variable they dont wantthen| to mess with, they create the variable with a preceeding underscore andthis:| create a read only property for it. So most of the time properties are | unnesesary and a simple readonly variable would do. something likeOr, what about private int _myVariable; public int myVarable { return _myVariable }; ? :)| | readonly int myVariable; | | instead of: | | private int _myVariable; | int myVariable() {return _myVariable;} | | i hope walter considers this, because it would save time What about other the protection attributes? The meaning of a "readonly" attribute overlaps with the protection attribute. What does something like readonly public int myVariable; declare? Or, similarly, what about readonly private int myVariable; Any attribute that controls read/write access needs to spell out how it interacts with the protection attributes. Perhaps some fancy protection attribute syntax would be better than a separate attribute - not that I can think of any good suggestions. -BenWhat about int myVariable {return myVariable;} Where myVariable is created implicitly. This code would be executed inside and outside the class for myVariable however the variable would only be changeable from within the class. It wouldn't completely solve the private situation but at least the code is still used in private situations.
Feb 15 2004
Matthew wrote:I guess your talking about the scope here. Yeah, parhaps scope should be fixed for readonly. -- -Anderson: http://badmama.com.au/~anderson/What about int myVariable {return myVariable;} Where myVariable is created implicitly. This code would be executed inside and outside the class for myVariable however the variable would only be changeable from within the class. It wouldn't completely solve the private situation but at least the code is still used in private situations.Or, what about private int _myVariable; public int myVarable { return _myVariable }; ? :)
Feb 15 2004
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:c0oicd$23pj$3 digitaldaemon.com...Matthew wrote:Nah! I was just being a witless smartarse. My point was that it's so easy to do what the OP wanted with the code he gave that there's little motivation to complicate the language by adding the posited keywordI guess your talking about the scope here. Yeah, parhaps scope should be fixed for readonly.What about int myVariable {return myVariable;} Where myVariable is created implicitly. This code would be executed inside and outside the class for myVariable however the variable would only be changeable from within the class. It wouldn't completely solve the private situation but at least the code is still used in private situations.Or, what about private int _myVariable; public int myVarable { return _myVariable }; ? :)
Feb 15 2004
yeah something like that. all im saying is that the current method of creating access properties for member variables is a waste of time, AND it leads to ugly underscores around the place which makes it look hungarian. And if im not mistaken Walter hates hungarian :) In article <c0ofel$1vnb$1 digitaldaemon.com>, Ben Hinkle says..."imr1984" <imr1984_member pathlink.com> wrote in message news:c0nvjl$1794$1 digitaldaemon.com... | ok so currently when people want a class member variable they dont want anyone | to mess with, they create the variable with a preceeding underscore and then | create a read only property for it. So most of the time properties are | unnesesary and a simple readonly variable would do. something like this: | | readonly int myVariable; | | instead of: | | private int _myVariable; | int myVariable() {return _myVariable;} | | i hope walter considers this, because it would save time What about other the protection attributes? The meaning of a "readonly" attribute overlaps with the protection attribute. What does something like readonly public int myVariable; declare? Or, similarly, what about readonly private int myVariable; Any attribute that controls read/write access needs to spell out how it interacts with the protection attributes. Perhaps some fancy protection attribute syntax would be better than a separate attribute - not that I can think of any good suggestions. -Ben
Feb 15 2004
yeah something like that. all im saying is that the current method ofcreatingaccess properties for member variables is a waste of time,I think you're overstating the case somewhatAND it leads to ugly underscores around the place which makes it look hungarian.I don't look at underscores and see Hungarian. SorryAnd if im not mistaken Walter hates hungarian :)He does My point is that this is something that's *easily* handled within the current faculties of the language. Adding new keywords is a very big deal, and it has to add very significant utility, that would otherwise be impossible, or require huge amounts of effort. typeof is a perfect example of something that should be a keyboard. TMP attributes, such as is_pod, is_scalar, etc. are also likely to fall into this category. Your requirement for readonly is understandable and nice, but it's just not sufficiently difficult to implement your requirements for it to represent much of an incentive unless other congruent uses for the keyboard are identified.In article <c0ofel$1vnb$1 digitaldaemon.com>, Ben Hinkle says...news:c0nvjl$1794$1 digitaldaemon.com..."imr1984" <imr1984_member pathlink.com> wrote in messageanyone| ok so currently when people want a class member variable they dont wantthen| to mess with, they create the variable with a preceeding underscore andthis:| create a read only property for it. So most of the time properties are | unnesesary and a simple readonly variable would do. something like| | readonly int myVariable; | | instead of: | | private int _myVariable; | int myVariable() {return _myVariable;} | | i hope walter considers this, because it would save time What about other the protection attributes? The meaning of a "readonly" attribute overlaps with the protection attribute. What does something like readonly public int myVariable; declare? Or, similarly, what about readonly private int myVariable; Any attribute that controls read/write access needs to spell out how it interacts with the protection attributes. Perhaps some fancy protection attribute syntax would be better than a separate attribute - not that I can think of any good suggestions. -Ben
Feb 15 2004
imr1984 wrote: [...]readonly int myVariable; instead of: private int _myVariable; int myVariable() {return _myVariable;} i hope walter considers this, because it would save timeYou like creating isles? What do you mean: public int myVariable() ... or protected int myVariable() ... And how to express: protected int _myVariable public int myVariable() ... Three new keywords for some syntactical sugar? If you want to save time while typing, then use a macro editor, that can transform your readonly keyword to the code you desire. I do not like your proposal. So long.
Feb 15 2004