I have a doubt about the pattern matching in SML. In the book "Programming Language Pragmatics (Second edition)" I read that in SML when you use the pattern matching in a function, the same variable can not appear more than once. The explanation is that pattern matching is used to check if the function can be found in a defined pattern, and not to check if variables are in relation to each others. But it has confused me: why something like this could not be implemented? Here is an example:
fun Eq nil = false
| Eq (e) = false
| Eq x::x::resto = true //Error
| Eq x::y::resto = false
This snippet of code check if the first two elements of a list are equal. So, why the third line of the code is wrong? Thank you.