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

Hello, Predef!

2 replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

Predef could use some love. I noticed Predef.Tuple only defines
overloads up to arity 9, but then I saw that I could input up to 22
elements and still get a result. How do you like this:

scala> Tuple(1,2,3,4,5,6,7,8,9).getClass
res0: java.lang.Class[_] = class scala.Tuple9

scala> Tuple(1,2,3,4,5,6,7,8,9,10).getClass
res1: java.lang.Class[_] = class scala.Tuple1

Up until 9 a TupleN is created, and then at 10 it decides that since
there is no such 10-arg version you must have meant to call the 1-arg
version with a 10-tuple. Funny stuff. Either Predef needs to go to 22
or not try at all.

Can the 18-month deprecated lower case primitive aliases be removed, and
the Integer/Character aliases?

I am realllly skeptical of the need to have a bunch of methods from
Console aliased in Predef. If we could at least deprecate the read*
methods, we could reclaim the global namespace one at a time.

Is there some technical constraint that causes many things to be in the
scala package object, but some others (Map, Set, etc.) to be in Predef?
Seems like the package object is the best way forward, where that can't
be done perhaps an explanatory comment.

Do we need val $scope = scala.xml.TopScope?

Can these commented out bits go? And scala.runtime.StreamCons, which is
not used except from the below commented-out method?

- /** any array projection can be automatically converted into an array */
- //implicit def forceArrayProjection[A](x: Array.Projection[A]): Array[A] = x.force !!! re-enable?
-
- //implicit def lazyStreamToConsable[A](xs: => Stream[A]) = new runtime.StreamCons(xs)

Adriaan Moors
Joined: 2009-04-03,
User offline. Last seen 42 years 45 weeks ago.
Re: Hello, Predef!
Is there some technical constraint that causes many things to be in the
scala package object, but some others (Map, Set, etc.) to be in Predef?
Seems like the package object is the best way forward, where that can't
be done perhaps an explanatory comment.
mostly, I think predef's inertia can be explained by fear of breaking the bootstrapLukas recently improved the situation (late last week), so maybe it warrants another shot  then again, it's a subtle beast and I try to avoid touching it myself (even with a 20-ft pole)
adriaan
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Hello, Predef!

On Sun, Nov 8, 2009 at 8:34 PM, Adriaan Moors
wrote:
>> Is there some technical constraint that causes many things to be in the
>> scala package object, but some others (Map, Set, etc.) to be in Predef?
>> Seems like the package object is the best way forward, where that can't
>> be done perhaps an explanatory comment.
>
> mostly, I think predef's inertia can be explained by fear of breaking the
> bootstrap
> Lukas recently improved the situation (late last week), so maybe it warrants
> another shot
> then again, it's a subtle beast and I try to avoid touching it myself (even
> with a 20-ft pole)

I think indeed most (all?) things in Predef can go to scala package
object. But we have to try this out to see whether it's really true.

Chheers

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