|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
default visibility of fields and methodsHi all,
it seems it is not clear what the default visibility for a field and method is. public for methods was it I think, but I thought it was private for fields... now it seems it was public... I am puzzled. Can we define that here and now, once and for all times? bye blackdrag --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: default visibility of fields and methodsOn 14 Jun 2006, at 11:20, Jochen Theodorou wrote: > Hi all, > > it seems it is not clear what the default visibility for a field > and method is. public for methods was it I think, but I thought it > was private for fields... now it seems it was public... I am > puzzled. Can we define that here and now, once and for all times? I think it's always been a bit fuzzy:) I think that the @Property change rather neatly solves the problem. As the only way of declaring a field is to supply a visibility modifier then there is no "default" visibility for a field. It's always explicit. Properties always have public accessor functions and private fields containing the value of the property. If users want non public acessor functions then they need to provide them explicitly: def x = 1 protected getX() { return this.x} private setX(x) {this.x = x} John Wilson The Wilson Partnership web http://www.wilson.co.uk blog http://eek.ook.org --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: default visibility of fields and methodsJohn Wilson schrieb:
> > On 14 Jun 2006, at 11:20, Jochen Theodorou wrote: > >> Hi all, >> >> it seems it is not clear what the default visibility for a field and >> method is. public for methods was it I think, but I thought it was >> private for fields... now it seems it was public... I am puzzled. Can >> we define that here and now, once and for all times? > > I think it's always been a bit fuzzy:) > > I think that the @Property change rather neatly solves the problem. As > the only way of declaring a field is to supply a visibility modifier > then there is no "default" visibility for a field. It's always explicit. hehe, correct.. I still have to get used to it ;) > Properties always have public accessor functions and private fields > containing the value of the property. > > If users want non public acessor functions then they need to provide > them explicitly: > > def x = 1 > > protected getX() { return this.x} > > private setX(x) {this.x = x} with the field x then private, right? bye blackdrag --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: default visibility of fields and methodsOn 14 Jun 2006, at 11:31, Jochen Theodorou wrote: > John Wilson schrieb: >> On 14 Jun 2006, at 11:20, Jochen Theodorou wrote: >>> Hi all, >>> >>> it seems it is not clear what the default visibility for a field >>> and method is. public for methods was it I think, but I thought >>> it was private for fields... now it seems it was public... I am >>> puzzled. Can we define that here and now, once and for all times? >> I think it's always been a bit fuzzy:) >> I think that the @Property change rather neatly solves the >> problem. As the only way of declaring a field is to supply a >> visibility modifier then there is no "default" visibility for a >> field. It's always explicit. > > hehe, correct.. I still have to get used to it ;) > >> Properties always have public accessor functions and private >> fields containing the value of the property. > > >> If users want non public acessor functions then they need to >> provide them explicitly: >> def x = 1 >> protected getX() { return this.x} >> private setX(x) {this.x = x} > > with the field x then private, right? Exactly! John Wilson The Wilson Partnership web http://www.wilson.co.uk blog http://eek.ook.org --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: default visibility of fields and methodsCan someone please tell me why I am suddenly
getting messages from this list again?? Every weeks, it seems that someone restores a backup copy of the email list, and I happen to be on it. So maybe someone could make a new backup copy??? This is about the fourth time I have suddenly found myself on some thread that I have long since disengaged from, if I was ever on it. Jochen Theodorou wrote: > Hi all, > > it seems it is not clear what the default visibility for a field and > method is. public for methods was it I think, but I thought it was > private for fields... now it seems it was public... I am puzzled. Can we > define that here and now, once and for all times? > > bye blackdrag > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |