Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 11:20
    bishabosha commented #11210
  • 11:02
    bishabosha commented #11210
  • 10:55
    bishabosha commented #11210
  • 10:54
    romanowski synchronize #11183
  • 10:53
    romanowski synchronize #11183
  • 10:52
    bishabosha synchronize #11210
  • 10:39
    liufengyun commented #168
  • 10:38
    liufengyun commented #168
  • 10:15
    bishabosha commented #11210
  • 10:14
    bishabosha commented #11210
  • 10:11
    odersky commented #11210
  • 10:10
    odersky commented #11210
  • 10:10
    odersky commented #11210
  • 09:57
    bishabosha commented #11210
  • 09:57
    bishabosha commented #11210
  • 09:55
    liufengyun edited #11186
  • 09:55
    liufengyun edited #11186
  • 09:54
    liufengyun commented #11186
  • 09:54
    liufengyun commented #11186
  • 09:54
    liufengyun commented #11186
Comcx
@Comcx
@smarter I got it. that makes sense. Thanks a lot!
Bjorn Regnell
@bjornregnell
@hypatian I just saw your comment on the @alpha notation https://gitter.im/lampepfl/dotty?at=5f908dcbeb82301c1a3e4419 and I included aspects of your "surprise" in a new discussion thread that I just opened here https://contributors.scala-lang.org/t/the-alpha-notation/4583 and if you want I think it would be great if you could elaborate your concerns there as well. @smarter Thanks again for the references that I included in the post -- if you have any tips on how I can improve the discussion contribution I'd be happy to edit/expand it.
PSBP
@PSBP-Library
General question: is there already a pretty printer for Dotty?
Bjorn Regnell
@bjornregnell
@PSBP-Library Have you tried https://scalameta.org/scalafmt/ ? (I guess it works for dotty as well (?), but I haven't tried it yet)
PSBP
@PSBP-Library
@bjornregnell I used scalafmt some months ago and had to do some preprocessing before getting it to work (and postprocessing afterwards). I could live with it but I silently assumed that scalafmt had been updated to make use of new Dotty syntax. Do you (or somebody else) know if this has been done? Thanks anyway.
Guillaume Martres
@smarter
Scalameta (and so by extension scalafmt) is adding dotty support but it's not done yet
PSBP
@PSBP-Library
No problem @smarter . I can live with the current situation. First things first. Keep on doing the great work!
Guillaume Martres
@smarter
@etorreborre you might be interested in explaining your usecase for implicit conversions with by-names in https://contributors.scala-lang.org/t/can-we-wean-scala-off-implicit-conversions/4388
Eric Torreborre
@etorreborre
Thanks I added a few words about my experience
Ben Fradet
@BenFradet
does anyone know of a "db" lib that has started leveraging the new structural types? I'm kind of curious how they're being used
megri
@megri
I'm not even sure what the changes between Scala 2 and 3 structural types are.. :)
Greg Zoller
@gzoller
Hi guys... I’m sure there is tremendous focus on getting Scala 3 and surrounding infrastructure projects airborne asap, but I think we may need to consider one more thing soon: test coverage. sbt-scoverage and sbt-jacoco seem semi-abandoned with no updates and minimal activity for a long time. If anyone has a working alternative, please share, otherwise this is going to be a key tooling gap. Since jacoco only looks at class files I was going to take a crack at upgrading it myself but the stock project wouldn’t build for me.
Guillaume Martres
@smarter
agreed, here's my student's project from a couple of years ago which did 90% of the work: http://guillaume.martres.me/code_coverage.pdf, but someone needs to step up to get it merged.
so: if you care, your help is welcome.
(and don't expect anyone at epfl/scalacenter/lightbend to do it, no one is available)
noti0na1
@noti0na1
What is the rule if we have conflicting bounds in function definitions? Shouldn't it be an error?
For example, def f[T >: String <: Int]: T = "" is accepted, but class C[T >: String <: Int] will throw an error.
Guillaume Martres
@smarter
there isn't any rule, it's best effort
but imagine that there's a class with an abstract method, you make a subclass of it and it turns out that the method you need to implement has conflicting bounds in the current context
maybe it still makes sense to allow you to define that method with a ??? rhs given that it can never be called since you might be able to do other things with that class
noti0na1
@noti0na1
Thanks, btw, how do I trigger the TypeBound case in TypeOps.boundsViolations.loop? I don't know how to pass a type bound as an argument.
Guillaume Martres
@smarter
_ >: X <: Y
(well ? instead of _ is the new syntax for wildcards but both work: http://dotty.epfl.ch/docs/reference/changed-features/wildcards.html)
Greg Zoller
@gzoller
@smarter thanks for the project info! Ill have a look. I know ypu guys are all intensly focused right now.
Alvin Alexander
@alvinj

I just ran into a situation where I get a different result with using futures in Dotty and Scala 2.13, and thought I’d mention it. When I run the code shown below with Scala 2.13.3 the result comes back in just over 1,000 ms, as expected.

But when I run it with Dotty ("0.27.0-RC1") it hangs and doesn’t produce output from f1 for about six seconds, when I see output that starts like this:

sbt:MultipleFutures2> leaving f1:  6005
java.util.concurrent.ExecutionException: Boxed Exception
    at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolve(Promise.scala:99)

The problem seems to be with the last sleep(5_000) statement. If I remove that, the futures come back in just over 1,000 ms (when I run this from inside the sbt shell). I originally had that statement in there to keep the JVM alive for when I ran this as a packaged jar file. If I change that to 8_000, f1 doesn’t return for over eight seconds.

I don’t know if I’m doing something wrong, but I thought I’d mention it. Here’s the code:

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}

object MultipleFutures2 extends App {

    // simulate a slow-running method
    def slowlyDouble(x: Int, delay: Long, name: String): Future[Int] = Future {
        println(s"entered $name:  ${delta()}")
        sleep(delay)
        println(s"leaving $name:  ${delta()}")
        x * 2
    }

    // time-related stuff that’s used later
    val startTime = System.currentTimeMillis
    def delta() = System.currentTimeMillis - startTime
    def sleep(millis: Long): Unit = Thread.sleep(millis)

    // create two futures
    val f1 = slowlyDouble(x=1, delay=1_000, name="f1")
    val f2 = slowlyDouble(x=2, delay=250, name="f2")

    // merge the futures in a for-comprehension
    val result = for {
        r1 <- f1
        r2 <- f2
    } yield (r1 + r2)

    // process their combined result
    result.onComplete {
       case Success(x) => {
           println(s"\nresult = $x (delta = ${delta()})")
       }
       case Failure(e) => e.printStackTrace
    }

    // important for a little parallel demo: keep the jvm alive
    sleep(5_000)

}
Guillaume Martres
@smarter
@alvinj rule of thumb is: never run futures in the constructor of an object, this can easily lead to deadlock as you try calling a method of the object while the object is being initialized
moving everything inside a main method is fine
also don't use extends App, that doesn't work the same in Scala 2 and Dotty since we don't support DelayedInit (that might be why you're seeing a difference in this case in fact)
use @main or write a main method by hand
App is basically deprecated.
Alvin Alexander
@alvinj
@smarter I’m sorry, I forgot about App being deprecated. I just changed it to a @main method and it works fine. I’m sorry about that.
Guillaume Martres
@smarter
cheers
it's not been widely publicized
Alvin Alexander
@alvinj
Also, thanks for that rule of thumb, that’s good to know.
To pay you back, I’ll be glad to publicize that a little bit. :)
Alexander Ioffe
@deusaquilus

Hi, here's a quick question. I am trying to unroll a tuple-cons during compile-time using inlines:

inline def isOneOf[T <: Tuple](inline tup: T, inline column:String): Boolean =
    inline tup match {
      case (head *: tail) => column == head || isOneOf(tail, column)
      case (leaf *: EmptyTuple) => column == leaf
    }
// and then:
isOneOf(("foo" *: EmptyTuple), "blah")

I'm getting a very big cannot reduce inline match with scrutinee message.
How come this doesn't work?

Tom Grigg
@griggt
@deusaquilus possibly related: #6698
Sakib Hadžiavdić
@sake92
oscar-broman
@oscar-broman
I think the point is just to show that unapply now can take an implicit parameter list
Sakib Hadžiavdić
@sake92
oh.. :smile:
oscar-broman
@oscar-broman
...which is really nice!
Sakib Hadžiavdić
@sake92
... indeed, but maybe not as a first example.
oscar-broman
@oscar-broman
Agreed
Alexander Ioffe
@deusaquilus
@griggt I think you're right
nafg
@nafg
Why do tuples nest to the right? My experience in Scala 2 is that when they end up nested they nest to the left
For instance a.zip(b).zip(c)
Jamie Thompson
@bishabosha
is the nightly broken again?
Guillaume Martres
@smarter
yep, tasty-inspector-example-project failed
Jamie Thompson
@bishabosha
oh yeah, that makes sense
Guillaume Martres
@smarter
can you make a PR for it?
Jamie Thompson
@bishabosha
ok