switch: using an expicit type as total is dangerous

Remi Forax forax at univ-mlv.fr
Mon Aug 24 14:08:26 UTC 2020


Ok, let restart this conversation, actually there are two issues.

1/ there is no syntax for saying that a type is total or not,
   if we take a close look to the different mails, at some points several of us uses different syntax to show that part of a pattern is total,
   Guy has used '_', i've proposed 'default', Brian used a blank line after the pattern and we all have used "var" a some points.


2/ using an explicit type for a total type is a footgun because the semantics will change if the hierarchy or the return type of a method switched upon change.
   Getting an error by the compiler when the behaviour change is important.
   And devs are used to change something in their code and fix all the errors reported by the compiler (using the refactoring capability of the IDE or not),
   if we let people to use an explicit type as a total pattern, the change of semantics will go undetected.


We have currently discussed about 1/ and 2/ at the same time, but conflating the two is maybe a mistake.

I believe that before talking about 1/, we should determine if we should tackle 2/ or not.

As i already said, for me 2/ is the real issue and i think Tagir agree.

Rémi


More information about the amber-spec-experts mailing list