Reply to Re: The Three Pillars of Dink v1.08
If you don't have an account, just leave the password field blank.
I didn't create dynamic scoping, I just implemented it. It's available in some programming languages, but most use static scoping (like C). Previous versions of Dink use pseudo-static scoping.
Has it anything to do with the separate int &y in bob()?
Indeed.
Dynamic scoping allows you to have multiple variables with the same name, and they won't interact with each other. You can do this now in Dink if you use seperate scripts or multiple instances of the same script (well, depending on the variable scoping issues).
Here's a slightly different example, where &save_x, &x, and &y are all global variables:
void main(void)
{
int &x = 4;
int &y = 6;
bob();
say_stop("&x, &y, &save_x", 1);
}
void bob()
{
int &y = 8;
function();
}
void function(void)
{
say_stop("&x, &y, &save_x", 1);
&x / 2;
}
What exactly happens in the say_stop statement in 'function'?
It looks for variables starting with the current function ('function'), and if the variable doesn't exist, we look for the variable in the calling function, ad infintum, until we reach the global variables.
function(void)
[No variables]
--------------------
bob(void)
&y = 8 //We use this &y
--------------------
main(void)
&x = 4 //We use this &x
&y = 6
--------------------
global
&x = 9
&y = 7
&save_x = 42 //We use this &save_x
Has it anything to do with the separate int &y in bob()?
Indeed.
Dynamic scoping allows you to have multiple variables with the same name, and they won't interact with each other. You can do this now in Dink if you use seperate scripts or multiple instances of the same script (well, depending on the variable scoping issues).
Here's a slightly different example, where &save_x, &x, and &y are all global variables:
void main(void)
{
int &x = 4;
int &y = 6;
bob();
say_stop("&x, &y, &save_x", 1);
}
void bob()
{
int &y = 8;
function();
}
void function(void)
{
say_stop("&x, &y, &save_x", 1);
&x / 2;
}
What exactly happens in the say_stop statement in 'function'?
It looks for variables starting with the current function ('function'), and if the variable doesn't exist, we look for the variable in the calling function, ad infintum, until we reach the global variables.
function(void)
[No variables]
--------------------
bob(void)
&y = 8 //We use this &y
--------------------
main(void)
&x = 4 //We use this &x
&y = 6
--------------------
global
&x = 9
&y = 7
&save_x = 42 //We use this &save_x