Skip to content
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

Revised given syntax #21208

Merged
merged 4 commits into from
Jul 25, 2024
Merged

Revised given syntax #21208

merged 4 commits into from
Jul 25, 2024

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 17, 2024

Update given syntax to latest discussed variant in the SIP

tests/pos/given-syntax.scala shows a semi-systematic list of possible syntax forms.

@odersky
Copy link
Contributor Author

odersky commented Jul 17, 2024

A good way to judge the merits or problems of the change to optional names is to look at the diff of tests/pos/typeclasses-arrow0.scala in https://github.com/scala/scala3/pull/21208/files. In my opinion, the double : looks not too bad now, so that I don't think replacing it with with is justified anymore. I believe the change that if there is an optional name, the colon always appears at the same point (after the identifier) helps. That way it becomes easy to see what is what. Previously, : could appear at various places which made it more confusing.

tests/pos/i13580.scala Outdated Show resolved Hide resolved
tests/pos/i13580.scala Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

These changes should be reverted

Copy link
Member

Choose a reason for hiding this comment

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

This a new neg test, it should have it's own .check file

@hamzaremmal hamzaremmal assigned odersky and unassigned hamzaremmal Jul 25, 2024
@odersky odersky force-pushed the revise-typeclasses branch from 51fb223 to 2e0047a Compare July 25, 2024 15:25
odersky added 4 commits July 25, 2024 20:13
Update given syntax to latest discussed variant in the SIP

tests/pos/given-syntax.scala shows a semi-systematic list of possible syntax forms.
@odersky odersky force-pushed the revise-typeclasses branch from 2e0047a to 62c71c0 Compare July 25, 2024 18:36
@odersky odersky merged commit 3dfd762 into scala:main Jul 25, 2024
28 checks passed
@odersky odersky deleted the revise-typeclasses branch July 25, 2024 21:58
@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 2024
GivenImpl ::= GivenType ([‘=’ Expr] | TemplateBody)
| ConstrApps TemplateBody
GivenConditional ::= DefTypeParamClause
| DefTermParamClause

Choose a reason for hiding this comment

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

is this really DefTermParamClause, or can it be FunParamClause instead? as far as i can tell, the difference is in modifiers (inline, erased) and default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It s a DefTypeParamClause. Modifiers and default values are allowed.

Choose a reason for hiding this comment

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

how do we resolve ambiguity between DefTermParamClause and '(' FunArgTypes ')', especially since a simple type can look like a parameter?

@odersky
Copy link
Contributor Author

odersky commented Dec 4, 2024

You mean, if the given actually implements a function? In that case the function has to come in parentheses.

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