rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Type parameter constraint syntax for safe matches.

Open jemc opened this issue 7 years ago • 3 comments

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 avatar Oct 11 '17 20:10 jemc

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

jemc avatar Oct 11 '17 20:10 jemc

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

Praetonus avatar Mar 18 '18 18:03 Praetonus

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.

shelby3 avatar Dec 06 '18 10:12 shelby3