asteroid icon indicating copy to clipboard operation
asteroid copied to clipboard

rename the 'in' predicate to 'member'

Open lutzhamel opened this issue 2 years ago • 1 comments

The in predicate clashes with the in keyword in for loops necessitating the use of excessive parens, e.g.

for (x,y) if x > y in pairlist do
   assert(x>y).
end

produces the error,

error: expected 'in' expression in for loop found 'do'.

This is due to the fact that in pairlist is interpreted as part of the conditional pattern

(x,y) if x > y in pairlist 

By removing the predicate in this ambiguity will disappear.

lutzhamel avatar Mar 25 '23 16:03 lutzhamel

The workaround is to put the pattern expression into parentheses,

for ((x,y) if x > y) in pairlist do
   assert(x>y).
end

There is no good way to fix this because here the language is inherently ambiguous.

lutzhamel avatar May 01 '23 17:05 lutzhamel