danilopedraza / symstatic

The Symstatic programming language code repository
https://symstatic.org/book
GNU General Public License v3.0
2 stars 0 forks source link

Symbol disambiguation #43

Open danilopedraza opened 1 month ago

danilopedraza commented 1 month ago

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:

Here is an example:

let f(val) := val + 1 # replace
let f(val) := 1 # match
danilopedraza commented 1 day ago

The above strategy will create a lot of problems. But I will go with it, just to see how it happens.