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

2.7.7 -> 2.8.0 changes

9 replies
Russel Winder 2
Joined: 2010-04-06,
User offline. Last seen 42 years 45 weeks ago.

Hi,

I found the following somewhere on the Web and it seems to do the right
thing (sort of) under 2.7.7. However under 2.8.0 I get an error
message. Is it something trivially simple I am missing?

class Mapper[A,B] ( data : List[A] , function : A => B ) {
val pmap = {
val buffer = new Array[B] ( data.length )
// Ranges are lazy but we need strict so the .toList
val mappers = for ( index <- ( 0 until data.length ).toList ) yield
Futures.future { buffer ( index ) = function ( data ( index ) ) }
for ( mapper <- mappers ) mapper ( )
buffer
}
}

scalac -optimise Pi_Scala_ParMap.scala
Pi_Scala_ParMap.scala:11: error: cannot find class manifest for element
type B
val buffer = new Array[B] ( data.length )
^
Pi_Scala_ParMap.scala:15: error: mapper of type Nothing does not take
parameters
for ( mapper <- mappers ) mapper ( )
^
two errors found

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: 2.7.7 -> 2.8.0 changes
Anything creating an Array or calling something that creates an Array now needs a manifest. Just replace [A,B] with [A,B : Manifest], or add (implicit man: Manifest[B]).   By the way, 2.8's Range is strict.

On Tue, Apr 6, 2010 at 2:57 PM, Russel Winder <russel [at] russel [dot] org [dot] uk> wrote:
Hi,

I found the following somewhere on the Web and it seems to do the right
thing (sort of) under 2.7.7.  However under 2.8.0 I get an error
message.  Is it something trivially simple I am missing?

       class Mapper[A,B] ( data : List[A] , function : A => B ) {
         val pmap = {
           val buffer = new Array[B] ( data.length )
           // Ranges are lazy but we need strict so the .toList
           val mappers = for ( index <- ( 0 until data.length ).toList ) yield
               Futures.future { buffer ( index ) = function ( data ( index ) ) }
           for ( mapper <- mappers ) mapper ( )
           buffer
         }
       }


scalac -optimise Pi_Scala_ParMap.scala
Pi_Scala_ParMap.scala:11: error: cannot find class manifest for element
type B
   val buffer = new Array[B] ( data.length )
                ^
Pi_Scala_ParMap.scala:15: error: mapper of type Nothing does not take
parameters
   for ( mapper <- mappers ) mapper ( )
                                    ^
two errors found


--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: 3Arussel [dot] winder [at] ekiga [dot] net" rel="nofollow">sip:russel [dot] winder [at] ekiga [dot] net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel [at] russel [dot] org [dot] uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



--
Daniel C. Sobral

I travel to the future all the time.
Sam Stainsby
Joined: 2009-01-14,
User offline. Last seen 42 years 45 weeks ago.
Re: 2.7.7 -> 2.8.0 changes

On Tue, 06 Apr 2010 15:40:26 -0300, Daniel Sobral wrote:

> [A,B : Manifest]

Interesting - I haven't seen this before . What is is called, and does it
do?

ijuma
Joined: 2008-08-20,
User offline. Last seen 22 weeks 2 days ago.
Re: Re: 2.7.7 -> 2.8.0 changes

On Wed, Apr 7, 2010 at 6:53 AM, Sam Stainsby
wrote:
> On Tue, 06 Apr 2010 15:40:26 -0300, Daniel Sobral wrote:
>> [A,B : Manifest]
> Interesting - I haven't seen this before . What is is called, and does it
> do?

It's called a context bound. The array SID talks a bit about it.

Best,
Ismael

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Re: 2.7.7 -> 2.8.0 changes
It's equivalent to my alternate solution:
replace [A,B] with [A,B : Manifest], or add (implicit man: Manifest[B])

On Wed, Apr 7, 2010 at 2:53 AM, Sam Stainsby <sam [at] sustainablesoftware [dot] com [dot] au> wrote:
On Tue, 06 Apr 2010 15:40:26 -0300, Daniel Sobral wrote:

> [A,B : Manifest]


Interesting - I haven't seen this before . What is is called, and does it
do?




--
Daniel C. Sobral

I travel to the future all the time.
Sam Stainsby
Joined: 2009-01-14,
User offline. Last seen 42 years 45 weeks ago.
Re: 2.7.7 -> 2.8.0 changes

On Wed, 07 Apr 2010 08:33:11 -0300, Daniel Sobral wrote:

> It's equivalent to my alternate solution:
>
> replace [A,B] with [A,B : Manifest], *or add (implicit man:
> Manifest[B])*

Except in the second case you have 'man', which can be accessed within
the class.

Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: Re: 2.7.7 -> 2.8.0 changes
The manifest can also be accessed when using context bounds - via implicitly[B] - as defined in Predef

On 7 April 2010 12:47, Sam Stainsby <sam [at] sustainablesoftware [dot] com [dot] au> wrote:
On Wed, 07 Apr 2010 08:33:11 -0300, Daniel Sobral wrote:

> It's equivalent to my alternate solution:
>
> replace [A,B] with [A,B : Manifest], *or add (implicit man:
> Manifest[B])*

Except in the second case you have 'man', which can be accessed within
the class.




--
Kevin Wright

mail/google talk: kev [dot] lee [dot] wright [at] googlemail [dot] com
wave: kev [dot] lee [dot] wright [at] googlewave [dot] com
skype: kev.lee.wright
twitter: @thecoda

ounos
Joined: 2008-12-29,
User offline. Last seen 3 years 44 weeks ago.
Re: Re: 2.7.7 -> 2.8.0 changes
(*Make that implicitly[Manifest[B]] )

2010/4/7 Kevin Wright <kev [dot] lee [dot] wright [at] googlemail [dot] com>
The manifest can also be accessed when using context bounds - via implicitly[B] - as defined in Predef

On 7 April 2010 12:47, Sam Stainsby <sam [at] sustainablesoftware [dot] com [dot] au> wrote:
On Wed, 07 Apr 2010 08:33:11 -0300, Daniel Sobral wrote:

> It's equivalent to my alternate solution:
>
> replace [A,B] with [A,B : Manifest], *or add (implicit man:
> Manifest[B])*

Except in the second case you have 'man', which can be accessed within
the class.




--
Kevin Wright

mail/google talk: kev [dot] lee [dot] wright [at] googlemail [dot] com
wave: kev [dot] lee [dot] wright [at] googlewave [dot] com
skype: kev.lee.wright
twitter: @thecoda


Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: Re: 2.7.7 -> 2.8.0 changes
yeah, that too :)

On 7 April 2010 13:20, Dimitris Andreou <jim [dot] andreou [at] gmail [dot] com> wrote:
(*Make that implicitly[Manifest[B]] )

2010/4/7 Kevin Wright <kev [dot] lee [dot] wright [at] googlemail [dot] com>
The manifest can also be accessed when using context bounds - via implicitly[B] - as defined in Predef

On 7 April 2010 12:47, Sam Stainsby <sam [at] sustainablesoftware [dot] com [dot] au> wrote:
On Wed, 07 Apr 2010 08:33:11 -0300, Daniel Sobral wrote:

> It's equivalent to my alternate solution:
>
> replace [A,B] with [A,B : Manifest], *or add (implicit man:
> Manifest[B])*

Except in the second case you have 'man', which can be accessed within
the class.




--
Kevin Wright

mail/google talk: kev [dot] lee [dot] wright [at] googlemail [dot] com
wave: kev [dot] lee [dot] wright [at] googlewave [dot] com
skype: kev.lee.wright
twitter: @thecoda





--
Kevin Wright

mail/google talk: kev [dot] lee [dot] wright [at] googlemail [dot] com
wave: kev [dot] lee [dot] wright [at] googlewave [dot] com
skype: kev.lee.wright
twitter: @thecoda

Sam Stainsby
Joined: 2009-01-14,
User offline. Last seen 42 years 45 weeks ago.
Re: 2.7.7 -> 2.8.0 changes

>> (*Make that implicitly[Manifest[B]] )

Nice! That should reduce some clutter in my code.

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