You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to list-match on constructor argument lists:
"nodeName"(int x, *value rest) // match an argument list that starts with an int and then zero or more value
and(*Bool args) // match the `and` constructor and both Bool arg and bind them to a list[Bool] named `args`
Currently when we have generic code on the level of type node we often have to use getName and getChildren in order to abstract from the number of arguments. The list-matching feature is much more elegant and shorter in such cases.
I'm guessing that this is a large change neither in the compiler nor in the interpreter. All we need to do is call getChildren first and then match the result against the list pattern, but only if at least one of the pattern variables is a list variable.
The text was updated successfully, but these errors were encountered:
The static type system would always return node in such a case
The dynamic type system would check the validity of the constructed tree against the name of the constructor and the grammar associated to it and throw an exception just like make does from the Type module.
like getChildren is hidden by matching, make will be hidden by splicing.
Describe the feature
I'd like to be able to list-match on constructor argument lists:
Currently when we have generic code on the level of type
node
we often have to usegetName
andgetChildren
in order to abstract from the number of arguments. The list-matching feature is much more elegant and shorter in such cases.I'm guessing that this is a large change neither in the compiler nor in the interpreter. All we need to do is call
getChildren
first and then match the result against the list pattern, but only if at least one of the pattern variables is a list variable.The text was updated successfully, but these errors were encountered: