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

Re: the shadow knows

5 replies
ichoran
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.


On Wed, Dec 7, 2011 at 2:40 PM, Paul Phillips <paulp [at] improving [dot] org> wrote:
On Wed, Dec 7, 2011 at 11:32 AM, Rex Kerr <ichoran [at] gmail [dot] com> wrote:
> I don't know why I should have to bother repeating the type information if
> all I want to do is forward parameters to A's constructor.

Because A could have more than one one-argument constructor.

That is a problem because...?

    class B(_,_,_) extends A(_,_,_,"Is this not perfectly clear?")
    class B(_,_) extends A("You get",_)("the idea, yes?",_)

--Rex


 
Auxiliaries are second-class enough without syntactically excluding
them from consideration.  Still, something in the spirit of this idea
would sure be nice.  I hate having to mkae up names for batons I'm
passing between relay racers.  They're batons! They're all just
batons! Stop trying to humanize them!

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: the shadow knows

On Wed, Dec 7, 2011 at 11:46 AM, Rex Kerr wrote:
> That is a problem because...?
>
>     class B(_,_,_) extends A(_,_,_,"Is this not perfectly clear?")
>     class B(_,_) extends A("You get",_)("the idea, yes?",_)

class A(x: Int) {
def this(x: String) = this(5)
def this(x: List[Int]) = this(x.head)
}
class B(_) extends A(_)

What's that?

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: the shadow knows

I didn't get the impression you had this in mind, but we could forward
all the auxiliaries which matched, which would actually be kind of
awesome because there's absolutely no way to do that at present. You
subclass something with five auxiliary constructors, you can write all
five of those constructors again and you can like it.

Michael Schmitz
Joined: 2011-11-01,
User offline. Last seen 42 years 45 weeks ago.
Re: the shadow knows

Or you could

class B(_: String) extends A(_)

On Wed, Dec 7, 2011 at 12:05 PM, Paul Phillips wrote:
> I didn't get the impression you had this in mind, but we could forward
> all the auxiliaries which matched, which would actually be kind of
> awesome because there's absolutely no way to do that at present.  You
> subclass something with five auxiliary constructors, you can write all
> five of those constructors again and you can like it.

ichoran
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.
Re: the shadow knows
That would be awesome indeed.  My answer was going to be "Choose the primary constructor, of course, unless it has the wrong number or type of arguments"--the reason being that the primary contstructor is where vals/vars must be declared, and matching that type is most likely to lead to unintentional shadowing.

But copying all of them would be far more awesome.  And possibly even a good idea.

  --Rex

On Wed, Dec 7, 2011 at 3:05 PM, Paul Phillips <paulp [at] improving [dot] org> wrote:
I didn't get the impression you had this in mind, but we could forward
all the auxiliaries which matched, which would actually be kind of
awesome because there's absolutely no way to do that at present.  You
subclass something with five auxiliary constructors, you can write all
five of those constructors again and you can like it.

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: the shadow knows

On Wed, Dec 7, 2011 at 12:29 PM, Rex Kerr wrote:
> That would be awesome indeed.  My answer was going to be "Choose the primary
> constructor, of course,

I did anticipate that answer, which is why I wrote "Auxiliaries are
second-class enough without syntactically excluding them from
consideration" to start. But it's not so bad, maybe we bumbled our
way toward a good idea.

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