On Tue, Mar 18, 2008 at 10:40 AM, Ingo Maier <
ingoem@...> wrote:
> David MacIver wrote:
> > a) Allow val, var and def in function parameters. val wouldn't do
> > anything (it's the same as the default). def introduces a call by name
> > parameter.
> > b) Constructor args are local by default unless given a visibility
> > modifier (private, public, protected). When given this modifier they
> > introduce a public member of the appropriate type.
>
> This would introduce a new keyword: public. It would further break with
True. I'd forgotten that wasn't already a keyword.
> Scala's default behavior that all members are public unless a private or
> protected modifier is given.
Well, not exactly. It changes the default about what is considered to
be a member. But I agree that it seems weirdly inconsistent.
Just to compound the feature proposal, if we're going to add a
keyword, let's do it properly. :-)
I've often been annoyed by the fact that there's no way of having
constructor local variables other than the constructor parameters.
It's not a big deal, but it's been annoying at various points. So why
not introduce a "local" privacy modifier for that (it doesn't have to
be a keyword outside of privacy modifiers, so it shouldn't break
existing code)? That gives us extra functionality, resolves the
problem with def constructor parameters and makes things nicely
consistent with the way public by default works.
Just to be clear, I don't think this is necessary for my proposal to
work. It just seems like the nicest solution.
I actually think that requiring call by name parameters for
constructors to be members wouldn't be the end of the world - 9 times
out of 10 it seems perfectly acceptable, and for the one time in 10
where it's not you can just pass a () => T as a normal constructor
argument.