Named patterns are special conditional patterns where the main pattern is always a variable and the definition is, the pattern x:p is identical to the pattern x if x is p where x is some variable and p is some pattern. However, syntactically the parser allows arbitrary patterns to appear where only a variable should appear, e.g.
lutz$ asteroid
Asteroid Version 1.1.3
(c) University of Rhode Island
Type "asteroid -h" for help
Press CTRL-D to exit
ast> let (a,b):(%integer,%integer) = (1,2).
error: unknown unifier type 'tuple' <<< better error message needed here
ast>
The parser allows the pattern but during pattern matching an error occurs precisely due to the fact that (a,b) is not a variable but a tuple. We need a better error message here such as variable expected or some such thing.
Named patterns are special conditional patterns where the main pattern is always a variable and the definition is, the pattern
x:pis identical to the patternx if x is pwherexis some variable andpis some pattern. However, syntactically the parser allows arbitrary patterns to appear where only a variable should appear, e.g.The parser allows the pattern but during pattern matching an error occurs precisely due to the fact that
(a,b)is not a variable but a tuple. We need a better error message here such asvariable expectedor some such thing.