The Dink Network

void( void )

April 24th 2005, 06:17 AM
spike.gif
Is there any real use for the ( void ) or do people put it there just out of habit? I tried scripting without them and haven't noticed a difference.
April 24th 2005, 06:48 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
In programming, you'd do a void if you want to run a part of code that doesn't have a return of a value at the end. Like:

void addOne(int a)
{
a += 1;
}

void because there's no return a; (which DinkC doesn't even have) at the end and (int a) because this function has a parameter and it's an integer. You can have returns in a void but then it doesn't return a value.

The second (void) means the function has no parameters which is the case in DinkC. Ie: void doSomething() is the same as void doSomething(void). That basically explains why it says (void).. but since there's nothing you can do to add parameters, it's just there because it should be there, not because there's much need, in DinkC anyway.
April 24th 2005, 06:48 AM
fairy.gif
glennglenn
Peasant He/Him Norway
GlennGlenn doesn't want a custom title. 
I think its like this Void main(void)
April 24th 2005, 08:57 PM
wizardb.gif
merlin
Peasant He/Him
 
It's not. It's void main().

There shouldn't be a void between the (). It's ANSI C to put it in there, but it's ANSI C++ to not put the void in (in fact, C++ requires main return an int value, by definition - there are ways to get around that though).
April 25th 2005, 12:24 PM
goblins.gif
igloo15
Peasant He/Him
 
can you actually do return statments in dinkc I didn't think it was possible.
April 25th 2005, 12:29 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
You can do return; but you can't return a value or so. It just exits the script.
April 25th 2005, 01:31 PM
peasantmg.gif
ehasl
Peasant He/Him
 
Yes, it stops a script, but doesn't kill it. That can be useful if you only want the bow to shoot if the "get_last_bow_power()" is more than a certain amount, for instance.