Reply to Re: The Three Pillars of Dink v1.08
If you don't have an account, just leave the password field blank.
Ok... I decided to add a few really awesome features to DinkC. I'll demonstrate it with an example:
{
make_global_function("common", "say_stuff");
int &testy = 88;
local_function(1, 2, 3, 4);
say_stop("&return", 1);
sp_x(1, 50);
say_stuff(&testy, 1);
say_stop("&return", 1);
external("common", "say_stuff", &testy, 1);
}
void local_function(void)
{
say_stop("&arg1, &arg2, &arg3, &arg4", 1);
return(6);
}
{
say_stop("I like to say stuff: &arg1", &arg2);
return sp_x(&arg2, -1);
}
6
I like to say stuff: 88
50
I like to say stuff: 88
You're limited to 9 arguments (&arg1 to &arg9). Because of inherent limitations, you're only allowed 8 arguments when you use 'external' to call a function.
There is one odd thing... if you want to return a variable or integer, you have to use the syntax return(5); (i.e. with parenthesis). If you want to return the value of a statement, it is best that you don't use parenthesis: return sp_x(1, -1);
I may end up removing dynamic scoping... the goal was to eliminate the need for adding argument/return-value support, and now that I've added it, dynamic scoping introduces complexities to DinkC that aren't needed.
table.c
void talk(void){
make_global_function("common", "say_stuff");
int &testy = 88;
local_function(1, 2, 3, 4);
say_stop("&return", 1);
sp_x(1, 50);
say_stuff(&testy, 1);
say_stop("&return", 1);
external("common", "say_stuff", &testy, 1);
}
void local_function(void)
{
say_stop("&arg1, &arg2, &arg3, &arg4", 1);
return(6);
}
common.c
void say_stuff(void){
say_stop("I like to say stuff: &arg1", &arg2);
return sp_x(&arg2, -1);
}
Output
1, 2, 3, 46
I like to say stuff: 88
50
I like to say stuff: 88
Notes
You can now define your own global DinkC functions, pass arguments to any custom function, and get the latest return value from any statement (including custom functions) by using the new built-in &return variable.You're limited to 9 arguments (&arg1 to &arg9). Because of inherent limitations, you're only allowed 8 arguments when you use 'external' to call a function.
There is one odd thing... if you want to return a variable or integer, you have to use the syntax return(5); (i.e. with parenthesis). If you want to return the value of a statement, it is best that you don't use parenthesis: return sp_x(1, -1);
I may end up removing dynamic scoping... the goal was to eliminate the need for adding argument/return-value support, and now that I've added it, dynamic scoping introduces complexities to DinkC that aren't needed.