In the programming languages with free symbols that I know, there is some syntax-level mechanism to make clear that an identifier represents a symbol to be matched or a value to be replaced in the code. For example, the Wolfram Language does this:
f[u_] := u + 1 (* the value that u holds is going to be replaced in the expression *)
f[u] := 1 (* This definition is going to be matched when I call f with the 'u' symbol *)
This is how Picat does it:
f(val) = 1. % Matches the 'val' symbol
f(Val) = Val + 1. % Replaces the value identified with Val
I need a way to make the same distinction. I propose to decide what interpretation to choose this way:
If the parameter is used in the function body, replace;
else, match.
Here is an example:
let f(val) := val + 1 # replace
let f(val) := 1 # match
In the programming languages with free symbols that I know, there is some syntax-level mechanism to make clear that an identifier represents a symbol to be matched or a value to be replaced in the code. For example, the Wolfram Language does this:
This is how Picat does it:
I need a way to make the same distinction. I propose to decide what interpretation to choose this way:
Here is an example: