Open lutzhamel opened 1 year ago
We cannot use juxtaposition as a way to parameterize patterns, it makes the language too ambiguous due to the confusion with function application. We can adopt the generics notation here,
ast> let pair = pattern<a> (x:*a,y:*a).
ast> let q:*pair<pattern %integer> = (1,2). -- here pair is a pair of integer values
ast> q
(1,2)
ast> let q:*pair<pattern %real> = (1.1,2.2). -- here pair is a pair of real values
ast> q
(1.1,2.2)
An idea on how to look at parameterized patterns. Currently Asteroid supports parameterized patterns via variables read from the environment,
This is very clumsy and prone to programming errors...think dynamically scoped functions. A nice way would be to actually have have parameters on the pattern. Something like this perhaps,
or in more concise form,