- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
2.8 spec clarification
Fri, 2010-05-21, 15:56
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
Sat, 2010-05-22, 15:07
#2
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
>
On Fri, May 21, 2010 at 4:52 PM, Mark Harrah <harrah@bu.edu> wrote:
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.
Yes.
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