I’m trying to figure out if Haskell uses dynamic or static scoping. I realize that, for example, if you define:
let x = 10
then define the function
let square x = x*x
You have 2 different ‘x’s’, and does that mean it is dynamically scoped? If not, what scoping does it use, and why?
Also, can Haskell variables have aliases (a different name for the same memory location/value)?
Thanks.
There are some things wrong in your statements…
In your example, x is not 10 in the function is just a argument to square, that can take any value (you can specify the type later) in this case 10 but just in this case.
Here is an example of aliases provided by Curt Sampson: