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

2.8 spec clarification

2 replies
Mark Harrah
Joined: 2008-12-18,
User offline. Last seen 35 weeks 3 days ago.

I submitted #3443 [1], which got closed as invalid because:

A#B is now equivalent to (x.B forSome { val x: A })

The type projection section (3.2.2) of the spec doesn't mention this and I
can't find the commit that implemented this or any related emails. There is a
related bug #3211 [2] that also got closed as invalid and the follow-up email
received no replies [3].

As far as I can tell, it isn't always equivalent either (see the last comment
in #3443), but I don't know what the specified behavior is to figure out if that
is expected.

I'm also a little unclear on how type designators are affected, since they are
defined in terms of type projections. Taking the expansions from Ch. 3 of the
spec with the new rule for A#B:

scala.Int
scala.type#Int
x.Int forSome { val x: scala.type }
x.type#Int forSome { val x: scala.type }
t#Int forSome { type t <: scala.type with Singleton }

Isn't this circular? The compiler manages ok, so I must wrong, but
clarification would be appreciated!

Finally, related to the spec and types, I'm interested in the answer to
another email asking about them [4], which unfortunately hasn't gotten a
response.

Thanks,
Mark

[1] http://lampsvn.epfl.ch/trac/scala/ticket/3443
[2] http://lampsvn.epfl.ch/trac/scala/ticket/3211
[3] http://scala-programming-language.1934581.n4.nabble.com/scala-projection-
types-or-existential-types-not-handled-correctly-in-2-8-
td2004664.html#a2004664
[4] http://scala-programming-language.1934581.n4.nabble.com/scala-SLS-
Question-td2004675.html#a2004675

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: 2.8 spec clarification


On Fri, May 21, 2010 at 4:52 PM, Mark Harrah <harrah@bu.edu> wrote:
I submitted #3443 [1], which got closed as invalid because:

 A#B is now equivalent to (x.B forSome { val x: A })

The type projection section (3.2.2) of the spec doesn't mention this and I
can't find the commit that implemented this or any related emails.  There is a
related bug #3211 [2] that also got closed as invalid and the follow-up email
received no replies [3].

Hi Mark,

You are right, the spec is not yet clear about this. I still need to go through it and adapt everything for the 2.8 rules.
 

As far as I can tell, it isn't always equivalent either (see the last comment
in #3443), but I don't know what the specified behavior is to figure out if that
is expected.

I'm also a little unclear on how type designators are affected, since they are
defined in terms of type projections.  Taking the expansions from Ch. 3 of the
spec with the new rule for A#B:

scala.Int 
scala.type#Int
  Yes. 
x.Int forSome { val x: scala.type }

No. The rule is: I the prefix is not stable, then convert to an existentially quantified stable prefix. If it is stable, the type
need not be rewritten. In your example, the double type projections get rewritten as follows.

    A # B # C
=  (a.B forSome a: A) # C
= ( b.C forSome (b: (a.B forSome a: A))

Cheers

 -- Martin

Mark Harrah
Joined: 2008-12-18,
User offline. Last seen 35 weeks 3 days ago.
Re: 2.8 spec clarification

On Friday 21 May 2010, martin odersky wrote:
> On Fri, May 21, 2010 at 4:52 PM, Mark Harrah wrote:
>
> > I submitted #3443 [1], which got closed as invalid because:
> >
> > A#B is now equivalent to (x.B forSome { val x: A })
> >
> > The type projection section (3.2.2) of the spec doesn't mention this and I
> > can't find the commit that implemented this or any related emails. There
> > is a
> > related bug #3211 [2] that also got closed as invalid and the follow-up
> > email
> > received no replies [3].
> >
>
> Hi Mark,
>
> You are right, the spec is not yet clear about this. I still need to go
> through it and adapt everything for the 2.8 rules.
>
>
> >
> > As far as I can tell, it isn't always equivalent either (see the last
> > comment
> > in #3443), but I don't know what the specified behavior is to figure out if
> > that
> > is expected.
> >
> > I'm also a little unclear on how type designators are affected, since they
> > are
> > defined in terms of type projections. Taking the expansions from Ch. 3 of
> > the
> > spec with the new rule for A#B:
> >
> > scala.Int
> >
> scala.type#Int
> >
>
> Yes.
>
>
> > x.Int forSome { val x: scala.type }
> >
>
> No. The rule is: I the prefix is not stable, then convert to an
> existentially quantified stable prefix. If it is stable, the type
> need not be rewritten. In your example, the double type projections get
> rewritten as follows.
>
> A # B # C
> = (a.B forSome a: A) # C
> = ( b.C forSome (b: (a.B forSome a: A))

Thanks, Martin. That rule makes sense.

-Mark

> Cheers
>

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