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

Type parameter constraint syntax for safe matches. #105

Open
jemc opened this issue Oct 11, 2017 · 3 comments
Open

Type parameter constraint syntax for safe matches. #105

jemc opened this issue Oct 11, 2017 · 3 comments

Comments

@jemc
Copy link
Member

jemc commented Oct 11, 2017

As discussed on today's sync call, due to @Theodus finding a standard library breakage in the planned fix for https://github.com/ponylang/ponyc/issues/2182#issuecomment-335878405, I think that adding syntax to our constraint language to fix that issue is a higher priority than previously thought.

Specifically, we need an RFC for new syntax that can be used in a type parameter constraint to require that the type parameter is safe to put in a match expression against some other type.

So, for ListNode, it might look like this (with a more elegant syntax):

class ListNode[A: canbematchedagainst None]

This would imply that a match expression containing the right-side operand type and the type argument would not be subject to the error "this match violates capabilities".

@jemc
Copy link
Member Author

jemc commented Oct 11, 2017

Note that this probably needs a bit more thought, but I'm just filing this ticket here to capture the discussion so far.

@Praetonus
Copy link
Member

I'm currently investigating a proposal for this, based on a relative complement type set operator.

@shelby3
Copy link

shelby3 commented Dec 6, 2018

Pointing out that I’m positing in #2182 that the problem might be more fundamental in the design choices for Pony’s type system. And that adding “hacks” for corner cases caused by design choices is probably not going to end well. If my hypothesis is correct, then perhaps redesigning Pony’s type system from the ground up is the real solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants