Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Sep 10, 2019

Syntax:

given x: T
given _: T

Allowed anywhere a pattern is allowed. This is useful in for expressions, i.e.

  for given x: T <- xs
  yield ... // `x` is a given here

It is also a necessary ingredient if we want to express implicit matches as a library method, which
is planned as a follow-up.

Based on #7150

@propensive
Copy link
Contributor

This will be a really useful feature. Though it's unfortunate that for given looks and sounds a lot like forgiven.

Change contextual docs to reflect three changes to `given` syntax:

 - put `given` inside the parentheses of parameters and arguments, as was suggested by @smarter.
 - change given import syntax to make `given` an import selector
 - change `the` to `theGiven`.

All of these should discussed in separate issues.
Following the discussion in scala#7151, choose `:` instead of `as` for given clauses.
Also: Allow inline givens to be whitebox
Syntax:

    given x: T

Allowed anywhere a pattern is allowed. This is useful in for expressions
and as a replacement of given matches, to name just two cases.
@odersky odersky merged commit 2b8ba68 into scala:master Sep 12, 2019
@odersky odersky deleted the change-given-impl branch September 12, 2019 13:02
@anatoliykmetyuk anatoliykmetyuk added this to the 0.19 Tech Preview milestone Sep 19, 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.

3 participants