This page is no longer maintained — Please continue to the home page at www.scala-lang.org

feature request: var[readvisibility, writevisibility]

3 replies
H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.

it seems i never sent it, so:

hi scala team,

i hereby suggest to think about the "valar". sorry, couldn't come up
with a better name. what i, and some other people on the scala user
mailing list are missing is a keyword for marking variables as "mutable
from inside, readonly from outside"

to satisfy the freaky who always want more, the syntax could be

class(var[_, this] x:Int)

the first parameter of var specifies the getter visibility. valid
arguments would be _ (meaning public), protected and private. the second
one specifies the setter visibility. contradicting declarations like
"private var[_, _]" should lead to a compile error. the []-thingy should
only be allowed to weaken the visibility, not the other way round

what do you think?

Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
Re: feature request: var[readvisibility, writevisibility]
Is
private var fooVar = //...
def foo = fooVar
so painful?

More food for the "scala is complex" fuddites i think - it's another syntax to remember, another meaning for underscores, and only a small saving in keystrokes on a not-that-big-a-deal use case.

My 2c!
Ken

On 10 September 2010 16:21, HamsterofDeath <h-star [at] gmx [dot] de> wrote:
it seems i never sent it, so:

 hi scala team,

i hereby suggest to think about the "valar". sorry, couldn't come up
with a better name. what i, and some other people on the scala user
mailing list are missing is a keyword for marking variables as "mutable
from inside, readonly from outside"

to satisfy the freaky who always want more, the syntax could be

class(var[_, this] x:Int)

the first parameter of var specifies the getter visibility. valid
arguments would be _ (meaning public), protected and private. the second
one specifies the setter visibility. contradicting declarations like
"private var[_, _]" should lead to a compile error. the []-thingy should
only be allowed to weaken the visibility, not the other way round

what do you think?

Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
Re: feature request: var[readvisibility, writevisibility]
I vote no.
High cost low benefit

Viktor KlangCode Connoisseurwww.akkasource.com
On Sep 10, 2010, at 8:53, Ken Scambler <ken [dot] scambler [at] gmail [dot] com> wrote:

Is
private var fooVar = //...
def foo = fooVar
so painful?

More food for the "scala is complex" fuddites i think - it's another syntax to remember, another meaning for underscores, and only a small saving in keystrokes on a not-that-big-a-deal use case.

My 2c!
Ken

On 10 September 2010 16:21, HamsterofDeath <h-star [at] gmx [dot] de (h-star [at] gmx [dot] de" rel="nofollow">h-star [at] gmx [dot] de)> wrote:
it seems i never sent it, so:

 hi scala team,

i hereby suggest to think about the "valar". sorry, couldn't come up
with a better name. what i, and some other people on the scala user
mailing list are missing is a keyword for marking variables as "mutable
from inside, readonly from outside"

to satisfy the freaky who always want more, the syntax could be

class(var[_, this] x:Int)

the first parameter of var specifies the getter visibility. valid
arguments would be _ (meaning public), protected and private. the second
one specifies the setter visibility. contradicting declarations like
"private var[_, _]" should lead to a compile error. the []-thingy should
only be allowed to weaken the visibility, not the other way round

what do you think?

H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.
Re: feature request: var[readvisibility, writevisibility]

the problem with

private var x_
def x = x_

is that i need 2 names for the same thing.

-------- Original-Nachricht --------
> Datum: Fri, 10 Sep 2010 08:59:35 +0200
> Von: Viktor Klang
> An: Ken Scambler
> CC: HamsterofDeath , "scala-debate [at] listes [dot] epfl [dot] ch"
> Betreff: Re: [scala-debate] feature request: var[readvisibility, writevisibility]

> I vote no.
>
> High cost low benefit
>
> Viktor Klang
> Code Connoisseur
> www.akkasource.com
>
> On Sep 10, 2010, at 8:53, Ken Scambler wrote:
>
> > Is
> > private var fooVar = //...
> > def foo = fooVar
> > so painful?
> >
> > More food for the "scala is complex" fuddites i think - it's another
> syntax to remember, another meaning for underscores, and only a small saving
> in keystrokes on a not-that-big-a-deal use case.
> >
> > My 2c!
> > Ken
> >
> > On 10 September 2010 16:21, HamsterofDeath wrote:
> > it seems i never sent it, so:
> >
> > hi scala team,
> >
> > i hereby suggest to think about the "valar". sorry, couldn't come up
> > with a better name. what i, and some other people on the scala user
> > mailing list are missing is a keyword for marking variables as "mutable
> > from inside, readonly from outside"
> >
> > to satisfy the freaky who always want more, the syntax could be
> >
> > class(var[_, this] x:Int)
> >
> > the first parameter of var specifies the getter visibility. valid
> > arguments would be _ (meaning public), protected and private. the second
> > one specifies the setter visibility. contradicting declarations like
> > "private var[_, _]" should lead to a compile error. the []-thingy should
> > only be allowed to weaken the visibility, not the other way round
> >
> > what do you think?
> >

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland