Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 06 2018 15:12
    @scalabot banned @fommil
  • Apr 19 2016 20:35
    @SethTisue banned @urmila007
soc
@soc
so we have one style for semicola, and I want to keep having one style for commas too
Dale Wijnand
@dwijnand
who's eager to add trailing commas on same-line lists?
Ichoran
@Ichoran
If you're refactoring from one line to multiple lines, it has some logic to it.
I'd really really prefer a serious attempt at comma inference. I can infer the commas to the point that I don't even notice them on multiple lines. Why can't the compiler?
Dale Wijnand
@dwijnand
I like it better too, but I don't think it would be accepted because it would make Scala too unlike Java.
My gut feeling is we have a very small "unlike-Java" budget
Ichoran
@Ichoran
Wellll we already have point free notation, which is way more unlike Java than comma inference is.
Dale Wijnand
@dwijnand
yeah, but that's last years budget :P
I'm talking about our current budget.
Ichoran
@Ichoran
Especially since, as I said, it's the newlines not the commas which I cue off of, and I think most people do given that forgetting commas in lists is a common compiler error.
Dale Wijnand
@dwijnand
Also there's talk of dropping infix notation
soc
@soc
language complexity budget doesn't magically replenish every year. when it's gone, it's gone.
that's why some people are working on removing stuff from the language, so that we get some breathing room for new worthwhile improvements.
Ichoran
@Ichoran
Chained infix notation is kind of monstrous, but I would say "don't do that" is a style decision. The "put anything infix not just symbols" rule is really nice, once you get your head around it.
It's easier and cleaner to read. Fewer distracting symbols that you never needed anyway.
But xs take k filter select map myMap dropRight drops
Dale Wijnand
@dwijnand
You're talking to the choir to me, I like infix a lot.
Ichoran
@Ichoran
is just...
Well, then we need to make a good case for why infix notation enhances the language enough to be worth the difference, if the talk of removing it is serious.
Dale Wijnand
@dwijnand
yep, see you at that SIP :P
Ichoran
@Ichoran
And I don't think it's all that hard. I mean, even x dot y for vectors is a pretty big win.
Anyway, now I have to uncatch my train :P
Seth Tisue
@SethTisue
to be clear, I think the talk is only about removing infix syntax unless something was explicitly declared @infix?
som-snytt
@som-snytt
The sbt example has me commenting lines in my "scratch" project. I remember putting junit at the bottom so it would always be last. I edit build.sbt with vi, not an IDE. I insert // or occasionally delete a line dd. Why is it unreasonable to expect sbt/scalac to understand trailing comma? OK, maybe for the use case, it is sbt's burden, who knows. I agree that it's tools all the way down. But if scalac can handle it without further ado, why not do so? Because I remember having to edit foo.sbt twice because of trailing comma, just because scalac is dumb. I want those thirty seconds of my life back, plus the time to switch contexts mentally.
libraryDependencies ++= Seq(
    "com.github.alexarchambault" %% "argonaut-shapeless_6.1" % "1.0.0-RC1",
  //"com.github.maqicode" %% "regextractor" % "0.1",
  //"com.typesafe" % "config" % "1.3.0",
  //"com.typesafe.akka" %% "akka-actor" % "2.3.11",
  //"org.testng" % "testng" % "6.1.1",
  "org.scala-lang" % "scala-compiler" % scalaVersion.value,
  "org.scala-lang" % "scala-reflect" % scalaVersion.value,
  "com.chuusai" %% "shapeless" % "2.3.0",
  //"org.scalaz" %% "scalaz-core" % "7.2.0",
  //"org.scalaz" %% "scalaz-core" % "7.0.3"
  //"com.github.som-snytt" %% "expecty" % "0.9" % "test",
  //"org.scalatest" % "scalatest_2.10" % "2.0" % "test",
  //"org.scalatest" %% "scalatest" % "2.0.1-SNAP4",
  "com.novocode" % "junit-interface" % "0.10" % "test",
  "junit" % "junit" % "4.10" % "test"
)
eugene yokota
@eed3si9n
it might be interesting to consider allowing semicolons as vararg separator, and thereby allowing them to be infered as @Ichoran is suggesting
Ichoran
@Ichoran
@SethTisue - That robs the feature of most of its usefulness, I think. Either people end up putting @infix all over like candy (hello, Java public!), or it's basically a non-feature. And you still don't get to use it on Java libraries.
@som-snytt - Why not use :: as your separator and terminate with Nil?
@eed3si9n - Why not allow semicolon inference in positions where multiple expressions are not allowed to convert to commas instead?

If I have

Seq(
  a
  b
  c
)

there is no way that semicolons are allowed. So it's either the method call a.b(c), or it's supposed to be commas.

Ichoran
@Ichoran
It gets it as a.b(c) now, whereas the equivalent thing in braces doesn't compile, but to allow point-free notation to span lines like that is kind of horrific anyway.
Ichoran
@Ichoran
@lihaoyi - Didn't you work on comma inference in Scalite? Did you run into any serious issues?
som-snytt
@som-snytt
@Ichoran Why doesn't the world? For scalac options I use "-deprecation -Xlint".split("\\s+").toSeq or similar, why doesn't everyone, instead of awkward Seq("-deprecation", "-Xlint")? But I agree that just as sbt might absorb some parsing hits, style tweaks can target tool-specific expressions, as you suggest.
Li Haoyi
@lihaoyi
@Ichoran no I did not work on comma inference with Scalite, yes I ran into lots of issues anyway
the whole thing is a crazy hack; have you seen the internals??? :D :D :D
it pre-dates any of my later scala-parser work; in theory it could be re-written in that stuff pretty easily, but as a 20-hour hack I never bothered
getting it to work with missing curlies was already pushing the envelope of it's technical hole...
also
if you're willing to drop the "Scalite" part
we use Coffeescript at work and run into tons of issues with comma-inference
no commas and no curlies and no parens makes trying to figure out what's a multi-statement block and what's a multi-arg multi-line function absolute hell
basically everything you write will compile, but people's mind-parsers are forever confused and it was a distinct sticking point in our internal web-engineer happiness survey
Ichoran
@Ichoran
@som-snytt - Maybe the world doesn't use list notation for SBT because the SBT docs use Seq. Now that I realized that I ought to be able to use List, I think I'm going to do that from now on. My SBT mindset is usually "don't touch ANYthing or it might stop working".
@lihaoyi - But we aren't dropping everything and turning it into Python without commas. The only change I'm proposing is that where it's already syntactically obvious that you must have commas, because you're directly inside parens and you can never do anything but have a single expression or multiple expressions separated by commas, that comma inference use the semicolon inference rules that already work when the parens are braces.
Thanks for the info about Scalite. I had remembered not seeing much punctuation, but wasn't sure if you'd tried comma inference.
Li Haoyi
@lihaoyi
you asked about Scalite, which is dropping everything and turning it into Python :P
Ichoran
@Ichoran
Yes, I'm just pointing out that my proposal is less ambitious.
There's a feature we already use in one context that should work equally well in another, and the two contexts are disambiguated perfectly already as far as I can tell.
Li Haoyi
@lihaoyi
yeah I understand that
I bring up coffeescript just to say
it is possible for this to go too far