sean.mcdirmid | 1 Dec 2007 01:23
Picon
Picon
Favicon

Re: [ANN] Scala 2.6.1-RC1

By stable API, we mostly means binary compatibility. Drop in only
works if the compiler itself hasn't changed. Note that highlighting
in the old plugin is going to get worse in the next release because
I've tweaked so many positions in the core compiler to help build
the new plugin but I haven't gone back and updated the code for 
the old plugin yet. I'm going to have to evaluate this and see how
bad it is. 

But expect an updated old plugin soon. Its mostly just a matter
of pushing a few buttons.

Sean

Quoting Ingo Maier <ingoem <at> googlemail.com>:

> Unfortunately, you cannot. Up to certain point, you can replace the 
> compiler and library jars in the ch.epfl.sdt.core.compiler plugin's lib
> 
> folder with those from the nightly builds (for the old plugin; don't 
> know what to do with the new one. Sean?). There isn't really a stable 
> compiler API and thus the longer the plugin hasn't been upgraded, the 
> more likely this will break.
> 
> However, Sean already said on this list that he will update the old 
> plugin soon.
> 
> Ingo
> 
> Normen Müller wrote:
> > Yeah, I have the same question.  Is it possible to use Eclipse update
(Continue reading)

sean.mcdirmid | 1 Dec 2007 01:44
Picon
Picon
Favicon

Re: 2.6.1-RC1 and Array[].slice

There is an implicit in Predefs that converts array projections into arrays
by calling force (toArray) automatically. It only works for array projections
and doesn't work for random access mutable projections. BUT you 
are using type inference to combine an array with an array projection, 
whose common superclass is mutable random access seq, so the implicit
coercion isn't firing. 

Here is one solution:

val responses : Array[Int] = 
  if (flag) responses_from_rpc.drop(1) else 
  responses_from_rpc

That will cause the implicit coercion to trigger early. The real solution
would be to change zip so that it takes an iterable or seq and not an 
array, there is no good reason that I can see why it requires an array!

Projections are more efficient because you can do N operations on an
array without creating/copying out an array each time. For slice/reverse
the projection of an array is really trivial (just transform the indices), so
it makes more sense to do them this way. The implicit coercion was
added to Predef to make it transparent to most users, but type inference
often defeats implicit coercions. You often can't have both!

Sean

Quoting Blair Zajac <blair <at> orcaware.com>:

> I have code that does something like this for a RPC method to save a
> network 
(Continue reading)

Blair Zajac | 1 Dec 2007 03:50
Gravatar

Re: 2.6.1-RC1 and Array[].slice

Thanks Sean for the description of the issue and the fixes.

I've opened a ticket to bookmark your suggestion to modify zip().

http://lampsvn.epfl.ch/trac/scala/ticket/260

Regards,
Blair

sean.mcdirmid <at> epfl.ch wrote:
> There is an implicit in Predefs that converts array projections into arrays
> by calling force (toArray) automatically. It only works for array projections
> and doesn't work for random access mutable projections. BUT you 
> are using type inference to combine an array with an array projection, 
> whose common superclass is mutable random access seq, so the implicit
> coercion isn't firing. 
> 
> Here is one solution:
> 
> val responses : Array[Int] = 
>   if (flag) responses_from_rpc.drop(1) else 
>   responses_from_rpc
> 
> That will cause the implicit coercion to trigger early. The real solution
> would be to change zip so that it takes an iterable or seq and not an 
> array, there is no good reason that I can see why it requires an array!
> 
> Projections are more efficient because you can do N operations on an
> array without creating/copying out an array each time. For slice/reverse
> the projection of an array is really trivial (just transform the indices), so
(Continue reading)

Oscar Picasso | 1 Dec 2007 04:22
Picon

Wiki - The Cake pattern or component-mixin

Hi,

On the wiki there is a "Cake pattern" entry with to Scalable Component Abstractions by Martin Odersky and Matthias Zenger.

In the paper there is no mention of a so called "Cake pattern". I was wondering whether the page was vandalized.

In any case this title is confusing.

Matt Hellige | 1 Dec 2007 04:34

Re: Wiki - The Cake pattern or component-mixin

No, the page was not vandalized. "The cake pattern" is the
unofficially-official name for the pattern described in the paper.
(See http://www.nabble.com/Inheriting-static-members-tf3619420.html
for some context.)  It's a sophisticated pattern with a number of
variations.

It would be very nice to have a good explanation of the pattern
outside the paper, particularly one targeted at the working
programmer, but so far I don't believe I have seen one. The best
explanation is still the original paper.

Matt

On Nov 30, 2007 9:22 PM, Oscar Picasso <oscarpicasso <at> gmail.com> wrote:
> Hi,
>
> On the wiki there is a "Cake pattern" entry with to Scalable Component
> Abstractions by Martin Odersky and Matthias Zenger.
>
> In the paper there is no mention of a so called "Cake pattern". I was
> wondering whether the page was vandalized.
>
> In any case this title is confusing.
>

--

-- 
Matt Hellige / matt <at> immute.net
http://matt.immute.net

Blair Zajac | 1 Dec 2007 05:55
Gravatar

Re: [ANN] Scala 2.6.1-RC1

Stéphane Micheloud wrote:
> We are pleased to announce version 2.6.1-RC1 of the Scala distribution:
> 
> 
> Version 2.6.1-RC1 is a bug fix release; it provides several library
> improvements and many bug fixes.
> 
>      http://scala-lang.org/downloads/changes.html#v2.6.1-RC1
> 
> Other release candidates may follow this version depending
> on bugs reported by the Scala community (no changes/additions,
> only bug fixes!); the final release (aka. 2.6.1-final) is
> planned in 2-3 weeks.
> 
> 
> Bye
> -- Stephane
> 

Thanks for 2.6.1-RC1!

This description doesn't match the ticket:

[fixed] - Improved tail call optimization with different instances. (#171)

Regards,
Blair

--

-- 
Blair Zajac, Ph.D.
CTO, OrcaWare Technologies
<blair <at> orcaware.com>
Subversion training, consulting and support
http://www.orcaware.com/svn/

sagar goel | 1 Dec 2007 06:27
Picon

Scala IDE

Hi,
i am using scala for a personal project  i am currently using the
eclipse plugin from the scala website but i was wondering if there are
any other good ones since this plugin seems to be immature.
Thanks,
Sagar

Matt Hellige | 1 Dec 2007 08:49

actors thread pool

I was under the impression that the actors library will dynamically
increase the number of worker threads in its thread pool. However, I
can't get this to work. Consider the following:
  import scala.actors.Actor._
  object Test {
    def main(args: Array[String]) {
      for (i <- List.range(0, args(0).toInt)) {
        actor {
          println("thread " + i + " about to block...")
          receive { case _ => }
        }
      }
      println("done spawning...")
    }
  }
I would expect to be able to provide any argument up to the maximum
thread pool size (256 by default), and see the actors library start
new threads as necessary (with some delay, of course, for the
heuristic as described in the paper).

For numbers of actors smaller than the initial thread pool size (4),
it works as expected (all of these terminated with ^C after awhile):
  [~dt/tmp2]% scala Test 4
  thread 0 about to block...
  thread 2 about to block...
  done spawning...
  thread 3 about to block...
  thread 1 about to block...
But for larger numbers of actors, I get the same output (only four messages):
  [~dt/tmp2]% scala Test 10
  thread 0 about to block...
  thread 1 about to block...
  thread 2 about to block...
  done spawning...
  thread 3 about to block...
If I increase the initial thread pool size, I see the expected output:
  [~dt/tmp2]% scala -Dactors.corePoolSize=10 Test 10
  thread 0 about to block...
  done spawning...
  thread 6 about to block...
  thread 1 about to block...
  thread 2 about to block...
  thread 3 about to block...
  thread 4 about to block...
  thread 5 about to block...
  thread 7 about to block...
  thread 8 about to block...
  thread 9 about to block...
Interestingly, the last example (with the increased thread pool)
requires roughly 2.5MB of heap, while the prior example (10 actors
with the default thread pool) requires 25MB of heap (!), and doesn't
work.

I looked briefly at the actors library code, and I can't find anything
that actually increases the thread pool size. But I only took a very
brief look. So what's happening here? Have I misunderstood how the
thread pool interacts with thread-based actors? Or is this a bug? If
it seems like a bug, I'll open an issue in Trac. (All of this is with
2.6.1-RC1.)

Thanks!
Matt

--

-- 
Matt Hellige / matt <at> immute.net
http://matt.immute.net

sean.mcdirmid | 1 Dec 2007 09:04
Picon
Picon
Favicon

Re: 2.6.1-RC1 and Array[].slice

I've thought of a better fix: have Array and Array.Projection 
implement a common supertype Array.ArrayLike and define 
the implicit coercion in Predef on that. Now the code will work 
without the type annotation. I still think zip's argument should
be changed to Iterable or Seq given that there is nothing to gain
from accepting an Array (boxing has to be done regardless). Hmm,
there could be a name clash with an existing zip method, I'll 
look into it.

Sean

Quoting Blair Zajac <blair <at> orcaware.com>:

> Thanks Sean for the description of the issue and the fixes.
> 
> I've opened a ticket to bookmark your suggestion to modify zip().
> 
> http://lampsvn.epfl.ch/trac/scala/ticket/260
> 
> Regards,
> Blair
> 
> sean.mcdirmid <at> epfl.ch wrote:
> > There is an implicit in Predefs that converts array projections into
> arrays
> > by calling force (toArray) automatically. It only works for array
> projections
> > and doesn't work for random access mutable projections. BUT you 
> > are using type inference to combine an array with an array projection,
> 
> > whose common superclass is mutable random access seq, so the
> implicit
> > coercion isn't firing. 
> > 
> > Here is one solution:
> > 
> > val responses : Array[Int] = 
> >   if (flag) responses_from_rpc.drop(1) else 
> >   responses_from_rpc
> > 
> > That will cause the implicit coercion to trigger early. The real
> solution
> > would be to change zip so that it takes an iterable or seq and not an
> 
> > array, there is no good reason that I can see why it requires an
> array!
> > 
> > Projections are more efficient because you can do N operations on an
> > array without creating/copying out an array each time. For
> slice/reverse
> > the projection of an array is really trivial (just transform the
> indices), so
> > it makes more sense to do them this way. The implicit coercion was
> > added to Predef to make it transparent to most users, but type
> inference
> > often defeats implicit coercions. You often can't have both!
> > 
> > Sean
> > 
> > Quoting Blair Zajac <blair <at> orcaware.com>:
> > 
> >> I have code that does something like this for a RPC method to save
> a
> >> network 
> >> round trip.
> >>
> >> // Just return the input for this example.
> >> def someRPCmethod[T](in : T) = in
> >>
> >> // Some flag if an additional parameter to the RPC should be added.
> >> val flag = true
> >>
> >> val requests = Array(1,2,3)
> >> val requests_for_rpc = if (flag) (Array(-1) ++ requests) else
> requests
> >> val responses_from_rpc = someRPCmethod(requests_for_rpc)
> >> val responses = if (flag) responses_from_rpc.drop(1) else
> >> responses_from_rpc
> >> requests.zip(responses).foreach { tuple => tuple }
> >>
> >> This works in 2.6.0 but in 2.6.1 the type of responses is not a
> >> Array[Int] but a 
> >>   RandomAccessSeq.Mutable[Int]{...} which cannot be passed to
> .zip():
> >>
> >> scala> <console>:7: error: type mismatch;
> >>   found   : RandomAccessSeq.Mutable[Int]{def reverse:
> >> Array.Projection[Int]; def 
> >> slice(Int,Int): Array.Projection[Int]; def take(Int):
> >> Array.Projection[Int]; def 
> >> drop(Int): Array.Projection[Int]}
> >>   required: Array[?]
> >>         requests.zip(responses).foreach { tuple => tuple }
> >>
> >>
> >> To get this to work in 2.6.1, I need to add a .toArray after the
> >> drop(1).
> >>
> >> I guess .drop doesn't generate a new array until requested for
> >> performance reasons?
> >>
> >> Is this intended?  As a developer in Scala using arrays, do I need
> to
> >> use .toArray?
> >>
> >> Should I file a report for this?
> >>
> >> Blair
> 

sean.mcdirmid | 1 Dec 2007 09:09
Picon
Picon
Favicon

Re: Scala IDE

You mean are we hiding a really mature/polished plugin that 
you could be using instead? :)

As far as I know, if you want a really mature solution, your 
best option is scala-mode in emacs: it works well for the 
feature set it advertises. 

There is a new Eclipse plugin (I'm working on
ATM this weekend), but I'm not sure when it will be stable
enough to call immature, let alone really mature (maybe 
if a deep-pockets company threw money at it).  I believe
we can get something that is immature yet stable enough
to be useful. 

Quoting sagar goel <sagargoel <at> gmail.com>:

> Hi,
> i am using scala for a personal project  i am currently using the
> eclipse plugin from the scala website but i was wondering if there are
> any other good ones since this plugin seems to be immature.
> Thanks,
> Sagar
> 


Gmane