Skip to content

Make given clauses come last #6513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 16, 2019
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 14, 2019

We now forbid given clauses followed by normal parameter clauses.
besides the syntactic awkwardness, there's also the problem
of eta expansion. Example:

  trait Universe { type T }
  def f given (u: Universe) (x: u.T)

How should we eta expand f? The usual algorithm would give:

  (x: u.T) => (f given the[Universe])(x)

but that's ill typed, since u is not defined on the outside.

(only last commit is new)

odersky added 17 commits May 12, 2019 12:52
So far pathTo(span) would only guarantee to return the path
to the closest tree enclosing `span` if trees were non-overlapping.
This is property does not hold for typed trees, yet `pathTo` is called
from `Interactive` on such typed trees.

This commit makes `pathTo` work correctly also for overlapping trees.
With given coming last, some of the no-overlaps and in-order position
checks have to be weakened. But with the more generalized pathTo
implementation, non-overlapping and in-order is not really needed anymore.
They printed as normal arguments before.
The previous syntax was unparseable without major contortions in the Parser.
Can do it now that we have a full bootstrap.
These were printed as old-style implicit parameters before.

This is in preparation for merging it with `Implied`. We already compensate for
it when printing modifiers by eliding it when it appear with `Param`.
Synthesized creator expressions for classes passed all parameters
as normal arguments. This works no longer with `given` clauses. We
have use `given` arguments for those.
We now forbid given clauses followed by normal parameter clauses.
besides the syntactic awkwardness, there's also  the problem
of eta expansion. Example:
```
  trait Universe { type T }
  def f given (u: Universe) (x: u.T)
```
How should we tea expand `f`? The usual algorithm would give:
```
  (x: u.T) => (f given the[Universe])(x)
```
but that's ill typed, since `u` is not defined on the outside.
Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Add" instead of "Added")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@odersky odersky requested a review from biboudis May 14, 2019 15:50
@odersky odersky merged commit 13ac0c4 into scala:master May 16, 2019
@allanrenucci allanrenucci deleted the change-given-last branch May 16, 2019 16:06
@anatoliykmetyuk anatoliykmetyuk added this to the 0.15 Tech Preview milestone May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants