Thread overview
readonly variables
Feb 15, 2004
imr1984
Feb 15, 2004
J Anderson
Feb 15, 2004
Ben Hinkle
Feb 15, 2004
J Anderson
Feb 15, 2004
Matthew
Feb 15, 2004
J Anderson
Feb 16, 2004
Matthew
Feb 15, 2004
imr1984
Feb 16, 2004
Matthew
Feb 15, 2004
Manfred Nowak
February 15, 2004
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


February 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 time
>
>  
>
I suggest the terms in and out.

out int myVariable; //Readonly
in int myVariable2; //Writeonly
inout int myVariable2; //Default

-- 
-Anderson: http://badmama.com.au/~anderson/
February 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




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

-- 
-Anderson: http://badmama.com.au/~anderson/
February 15, 2004
"J Anderson" <REMOVEanderson@badmama.com.au> wrote in message news:c0oh8p$22ea$1@digitaldaemon.com...
> 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.
> >
> >-Ben
> >
> >
> 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 };

?

:)


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


February 15, 2004
Matthew wrote:

>>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 };
>
>?
>
>:)
>  
>
I guess your talking about the scope here.  Yeah, parhaps scope should be fixed for readonly.

-- 
-Anderson: http://badmama.com.au/~anderson/
February 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 time

You 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.
February 16, 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,

I think you're overstating the case somewhat

> AND it leads to ugly
> underscores around the place which makes it look hungarian.

I don't look at underscores and see Hungarian. Sorry

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


February 16, 2004
"J Anderson" <REMOVEanderson@badmama.com.au> wrote in message news:c0oicd$23pj$3@digitaldaemon.com...
> Matthew wrote:
>
> >>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 };
> >
> >?
> >
> >:)
> >
> >
> I guess your talking about the scope here.  Yeah, parhaps scope should be fixed for readonly.

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 keyword