by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 21:41
    odersky synchronize #9343
  • 21:30
    odersky opened #9343
  • 20:56
    TheElectronWill commented #9271
  • 20:54
    TheElectronWill synchronize #9271
  • 20:28

    nicolasstucki on master

    Use new extension syntax in `Ma… Use new extension syntax in `sc… Use new extension syntax in IAr… and 3 more (compare)

  • 20:28
    nicolasstucki closed #9336
  • 20:15
    nicolasstucki assigned #9342
  • 20:14
    nicolasstucki commented #9342
  • 20:04
    nicolasstucki labeled #9342
  • 19:56
    odersky assigned #9337
  • 19:56
    odersky unassigned #9337
  • 19:56
    odersky commented #9337
  • 19:32
    odersky closed #9333
  • 19:26
    dotty-bot commented #9333
  • 19:08
    edolgy labeled #9342
  • 19:08
    edolgy opened #9342
  • 17:35
    odersky commented #9333
  • 16:35
    dotty-bot commented #9333
  • 16:34
    odersky commented #9333
  • 16:30
    nicolasstucki synchronize #9336
Nicolas Rinaudo
@nrinaudo
Option-less pattern matching
Nicolas Rinaudo
@nrinaudo
this lead me to believe that pattern matching didn't rely on Option, when it meant it can work without Option
Guillaume Martres
@smarter
yes
Nicolas Rinaudo
@nrinaudo
ok, so that clarifies everything. I was stuck by the fact that it magically worked without special casing Some
thank you for your time and explanations
Guillaume Martres
@smarter
:)
it's true that http://dotty.epfl.ch/docs/reference/changed-features/pattern-matching.html is missing documentation on the concept of an irrefutable apply
Nicolas Rinaudo
@nrinaudo
I would actually really like to know more about that, and how the behaviour changed since Scala 2. It clearly changed, and I'd love to know to what extent
Guillaume Martres
@smarter
Opened an issue: lampepfl/dotty#6490
Nicolas Rinaudo
@nrinaudo
the code you linked clarifies it quite a bit as well, thanks
I have another, entirely unrelated question. Is there a particular reason for enum types not to extend Serializable and, when all cases are products, Product?
Guillaume Martres
@smarter
no particular reason
Nicolas Rinaudo
@nrinaudo
is this something that could be considered?
scala> enum Foo {
     |   case Bar(i: Int)
     |   case Baz(b: Boolean)
     | }
     | 
     | List(new Foo.Bar(1), new Foo.Baz(true))
// defined class Foo
val res1: List[Foo & Product & Serializable] = List(Bar(1), Baz(true))
I was really hoping for the Product & Serializable wart to disappear :/
Guillaume Martres
@smarter
if you don't use new then you get the apply companion that returns Foo so you just have a List[Foo]
Nicolas Rinaudo
@nrinaudo
absolutely. The wart is better hidden, but it's still here
Guillaume Martres
@smarter
but if no one uses new, then is it really worth the effort to special-case Serializable and Product in enums ?
it'd be more interesting to do this for regular sealed traits
but then it still seems a weird special-casing than you cannot opt out of
Nicolas Rinaudo
@nrinaudo
if it's complicated, probably not. But if not, and you already have a special case for case classes, why not special case ADTs?
Guillaume Martres
@smarter
what do you mean by special case for case classes ?
Nicolas Rinaudo
@nrinaudo
case classes are Product with Serializable, right?
Guillaume Martres
@smarter
it's not complicated to implement, it's just irregular
yes
but that's unconditional
Nicolas Rinaudo
@nrinaudo
I'm arguing Serializable should then be unconditional for enums
Product is slightly weirder, since not all cases need be products
Guillaume Martres
@smarter
what if I extend something which is impossible to serialize ?
Martijn Hoekstra
@martijnhoekstra
if all members of some sealed trait Foo extend Bar, then Foo extends Bar naively sounds like a reasonable rule that would solve all potential issues
Nicolas Rinaudo
@nrinaudo
don't you have the same problem with case classes?
Guillaume Martres
@smarter
@martijnhoekstra It's not completely crazy but it has the potential to break stuff
yes, you're not supposed to do that with case classes
Nicolas Rinaudo
@nrinaudo
so that's where my point of case classes are a special case came from
I was suggesting to make them less of a special case, or at least to make ADTs a special case, not just case classes
I do understand your point about breaking stuff though. I'm just not sure you'd break more stuff than currently
(I also understand that this kind of decision cannot be taken on a hunch)
Guillaume Martres
@smarter
no, you'll have to go to https://contributors.scala-lang.org/ and convince people to care :)
Nicolas Rinaudo
@nrinaudo
Ah. I thought this was the right avenue for that
ok then, thanks!
@smarter I think I'll end up crediting you for half of my slides at scaladays
Guillaume Martres
@smarter
haha
what's the topic of your talk ?
Nicolas Rinaudo
@nrinaudo
Best Practices I wish someone'd told me about
stuff like... extends Product with Serializable for ADTs
Guillaume Martres
@smarter
nice
Nicolas Rinaudo
@nrinaudo
or return Some when you can in extractors
there's a bit of a pattern :)
I'm trying to see how much of my deck is made irrelevant by dotty