Dotty: Change syntax for self types?

Created on 5 Oct 2019  Â·  3Comments  Â·  Source: lampepfl/dotty

The current self type syntax clashes with the use of :for indented arguments (which is by itself at the moment an experimental language extension). Namely:

class C extends Seq[Int] with
  foreach: x =>
    println(x)

This should print each element of the sequence but with the old self type syntax this would be treated as a self type declaration foreach: x => followed by a println.

I wonder whether we can tweak the self type syntax. One idea would be to write

trait T with 
  (self: C)
  ...

instead of

trait T with
  self: C =>
  ...

The => is arguably misleading here anyway since it suggests a lambda.

New and old syntax can co-exist for the time being. The new syntax would be mandatory if the class body is introduced with a with. In the medium term, the old syntax could be dropped.

language enhancement

Most helpful comment

Seriously: I think this is just another illustration that the indentation experiment has gone way off the rails. It's causing knock-on change after knock-on change, and none of it is justified by actual community demand. It has turned Scala 3 from a cool, conservative set of changes to a radical revamp of the entire language that is much more likely to provoke a community split.

(And no, this isn't the one true straw that breaks the camel's back, but the endless stream of language changes that I've been seeing over the past month or two is really disturbing...)

All 3 comments

Seriously: I think this is just another illustration that the indentation experiment has gone way off the rails. It's causing knock-on change after knock-on change, and none of it is justified by actual community demand. It has turned Scala 3 from a cool, conservative set of changes to a radical revamp of the entire language that is much more likely to provoke a community split.

(And no, this isn't the one true straw that breaks the camel's back, but the endless stream of language changes that I've been seeing over the past month or two is really disturbing...)

I agree with Justin

On Sat, Oct 5, 2019, 10:15 PM Justin du Coeur, AKA Mark Waks <
[email protected]> wrote:

Seriously: I think this is just another illustration that the indentation
experiment has gone way off the rails. It's causing knock-on change
after knock-on change, and none of it is justified by actual community
demand. It has turned Scala 3 from a cool, conservative set of changes to a
radical revamp of the entire language that is much more likely to
provoke a community split.

(And no, this isn't the one true straw that breaks the camel's back, but
the endless stream of language changes that I've been seeing over the past
month or two is really disturbing...)

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/lampepfl/dotty/issues/7373?email_source=notifications&email_token=AAAYAUBJA3AM6AHH5F3IU73QNFC2ZA5CNFSM4I5YU7N2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAN74CI#issuecomment-538705417,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAYAUGHYCE3PC5AX6K5RSLQNFC2ZANCNFSM4I5YU7NQ
.

I agree that the question as it stands is tied too much with indentation experiments, which might not come to fruition. So we should ask ourselves whether we would welcome this change independent of indentation, and there the answer is probably no, it's not worth it.

That said, self types do feel like a weird little edge case of the language. So, maybe we can replace them with something nicer?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julienrf picture julienrf  Â·  3Comments

NightMachinary picture NightMachinary  Â·  3Comments

liufengyun picture liufengyun  Â·  3Comments

hmf picture hmf  Â·  3Comments

ohze picture ohze  Â·  3Comments