Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:46

    smarter on master

    error when postfix and postfixO… update scalap to latest version… use ctx.echo instead of println… and 1 more (compare)

  • 14:46
    smarter closed #8388
  • 14:46
    smarter closed #5498
  • 14:34
    martijnhoekstra synchronize #8480
  • 11:59
    Jacopo47 starred lampepfl/dotty
  • 11:39
    odersky commented #8624
  • 11:33
    martijnhoekstra synchronize #8480
  • 10:51
    odersky unassigned #8624
  • 10:51
    odersky assigned #8624
  • 10:29
    odersky commented #8611
  • 08:34

    anatoliykmetyuk on master

    Fix some quotes in Parser's sim… Merge pull request #8625 from d… (compare)

  • 08:34
    anatoliykmetyuk closed #8625
  • 08:27
    anatoliykmetyuk assigned #8604
  • 07:23
    Philippus synchronize #8604
  • Mar 27 22:49
    liufengyun commented #8561
  • Mar 27 22:05
    dotty-bot commented #8561
  • Mar 27 21:19
    dotty-bot commented #8561
  • Mar 27 21:18
    liufengyun commented #8561
  • Mar 27 20:55
    robstoll commented #8394
  • Mar 27 20:52
    robstoll synchronize #8394
Guillaume Martres
@smarter
I pinged him
but if there's an actual issue then issues are always best yes :)
Dale Wijnand
@dwijnand
Btw, I think it's doing Dotty a disservice to declare this as a "dropped feature" rather than an improvement https://dotty.epfl.ch/docs/reference/dropped-features/limit22.html :D
Paolo G. Giarrusso
@Blaisorblade
@noelwelsh it seems @smarter's idea passes typer and fail refchecks, or sth: https://gist.github.com/Blaisorblade/1835dbfa8b2d015a810f3d0cf24412b8. Intuitively allowing this match type to be covariant seems a plausible feature request, but I'm not sure.
Guillaume Martres
@smarter
the thing you match on has to be invariant for match type soundness
(notice the nested N match {)
Paolo G. Giarrusso
@Blaisorblade
the compiler says so, but why? If the match reduces on N, a stricter type should give the same result. I guess the problem are stuck matches?
Guillaume Martres
@smarter
I forgot.
Paolo G. Giarrusso
@Blaisorblade
anyway at least we know you were right — if Elem is marked as covariant, typer accepts the program (but we get an error after typer)
odersky
@odersky
The covariant requirement was necessary with the previous reduction. But with the new stricter overlapping checks we might be able to drop it. @OlivierBlanvillain should have a look.
Noel Welsh
@noelwelsh
I made an alternate and more explicit implementation here: https://gist.github.com/noelwelsh/57f7609e80fb7b752547fdd3e13f08aa It fails in a different way but I feel like I'm just pushing the error messages around and there is some fundamental flaw I'm not seeing.
Olivier Blanvillain
@OlivierBlanvillain

The covariant requirement was necessary with the previous reduction. But with the new stricter overlapping checks we might be able to drop it. @OlivierBlanvillain should have a look.

I'm pretty sure none of that has changed. What example should I look at?

odersky
@odersky
The one by @noelwelsh
Noel Welsh
@noelwelsh
One attempt is here: https://gist.github.com/noelwelsh/57f7609e80fb7b752547fdd3e13f08aa
An earlier attempt is higher up in the thread :point_up: March 27, 2020 1:28 PM
Greg Zoller
@gzoller
I noticed that some collection classes scramble their class names, for example scala.collection.immutable.List -> scala.collection.immutable.$colon$colon (which, confusingly, so does Seq) Are Seq derivatives the only collections scrambled this drastically (i.e. they don't contain the class name at all)?
Guillaume Martres
@smarter
it's not List that's scrambled
:: is a subclass of List
:: is not a valid name of the JVM so it gets encoded
Sébastien Doeraene
@sjrd
Well ... actually it is a valid name on the JVM. But not in Java.
Sébastien Doeraene
@sjrd
The only characters that are not allowed on the JVM are ; / . [ (and < for method names)
Greg Zoller
@gzoller
This helps, thank you... But I'm still wondering about ::. This is "special" because its not the actual name of the class, i.e. List, or Seq. It seems most (all?) of the other encoded collection class names feature the name of the class, like Map gives you: scala.collection.immutable.Map$Map1, so the "Map" class name is clear there. Are there others that remove the class name entirely, like ::?
Sébastien Doeraene
@sjrd
It is the actual name of the case class ::, which is a subclass of List.
Greg Zoller
@gzoller
Are there others that follow that pattern?
(changing the "natural" name of the collection, e.g. List, for something more symbolic)
Michael Pilquist
@mpilquist
Some / None is a good example
Guillaume Martres
@smarter
it's not a name change
Michael Pilquist
@mpilquist
Some is to :: as Option is to List -- used as constructor and extractor and exists in same package as supertype
Greg Zoller
@gzoller
That gives me scala.Some/scala.None$, which is easy to work with. (A number of the collections encode "extra" info after the classname by mixing $... after the class)
Noel Welsh
@noelwelsh
I think the $ after a name indicates a Scala object.
name encoding is not specific to collections
Greg Zoller
@gzoller
ok
Paolo G. Giarrusso
@Blaisorblade
name encoding is one half.
Michael Pilquist
@mpilquist
Here's another example of name encoding of a class: https://www.scala-lang.org/api/current/scala/$less$colon$less.html
Paolo G. Giarrusso
@Blaisorblade
a class Foo extending Bar but not having Bar in the name is the other half...
Greg Zoller
@gzoller
? what's the other 1/2?
Paolo G. Giarrusso
@Blaisorblade
and that happens already in Java
Greg Zoller
@gzoller
yes, that's true
Paolo G. Giarrusso
@Blaisorblade
your Map$Map1 example is the special one — but that only happens because Map1 is literally nested inside Map :-)
Greg Zoller
@gzoller
that makes sense
Martijn Hoekstra
@martijnhoekstra
In an interpolation, the string parts are a Literals. The start position of the first literal is that of the opening quote, and the rest just the start of the string. I need to get the position of the start of the string, how can I determine that?
I suppose that comes down to how do I know if it's single or triple quoted
Paolo G. Giarrusso
@Blaisorblade
@martijnhoekstra are you asking about Tasty reflection or the compiler side? There’s probably a better API, but from the compiler side, Trees store their SourcePosition which stores a SourceFile so you can access the actual characters in the worst-case via https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/util/SourceFile.scala#L70
(not that I’m entirely sure I get the question exactly — what you describe sounds inconsistent, possibly by oversight)
Martijn Hoekstra
@martijnhoekstra
It's on the compiler side, in the transforms on interpolators @Blaisorblade
so s"""foo $bar baz""" matches Apply(Select(Apply(StringContextApply(), List(Literals(strs))), _)
and the start positions of those strs point at the first quote and the space after $bar
oh, I can use that in a pinch, the position of f is the length of foo before the end of the first literal
should have brought my rubber duck