The Dink Network

Procedure opening/closing brackets

September 24th 2005, 01:25 PM
spike.gif
How exactly do these work?? I've noticed that sometimes you don't even need them at all, and sometimes they're just as important as you think.
September 24th 2005, 02:50 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Magic voodoo.

The DinkC script parsing is not very understandable. My advice is to code as best as you can, and use curly braces everywhere.
September 24th 2005, 03:39 PM
burntree.gif
Striker
Noble She/Her United States
Daniel, there are clowns. 
My general policy is that if you only have one statement below the "if()", you don't need brackets. Any more than that, and I use them. I have yet to have a problem with this method.
September 24th 2005, 04:36 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Well, when the body of the if-statement is only one command/expression/whatever, you don't necessarily need them because that's part of the syntax. But the body can also have more commands/expressions/etc and then you need them because otherwise, the engine/compiler doesn't know they're all part of the body of the if-statement

We're doing that @ uni these days so that's why You can consistently use brackets only when necessary (so not when there's only 1 thing in the if-statement's body) but on the other hand, it's generally better to use them everywhere because you can see at all times what starts and ends where (and, if you wanted to add something else, you'd need to add those brackets again to make sure it functions properly - and, when you forget that, you'd wonder why it's not working right )
September 24th 2005, 06:00 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
That works, except when assigning variables.

This doesn't work:

if (&bob == 3) &bob = 4;
September 24th 2005, 06:36 PM
burntree.gif
Striker
Noble She/Her United States
Daniel, there are clowns. 
What about?

if (&bob == 3)
&bob = 4;
September 24th 2005, 08:38 PM
spike.gif
Magic voodoo.

Hmm, yeah, I was just wondering after realizing scripts with only main() didn't need

void main()
{
}
September 24th 2005, 08:39 PM
spike.gif
I use that policy too. It's annoying using brackets especially for multiple if()'s and one-liners in a row. I get the feeling my script's more bound to randomly crash without the brackets, though. Superstition... may be. ^^
September 24th 2005, 08:45 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
I don't remember... I was just looking through a DinkC script, and I used something very similar, but it worked.

So I could be spreading falsehoods out to corrupt the minds of Dink developers, hmm.
September 25th 2005, 06:55 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Hmm, if

if (&bob == 3) &bob = 4;

doesn't work, then Striker's example shouldn't work either because it's basically the same syntax except using 1 more line - you could write a whole program (not a DinkC script, DinkC is very limited ) on 1 line but that wouldn't be readable for us Or perhaps DinkC has odd logic and redink1's example doesn't work, and Striker's example does
September 25th 2005, 01:34 PM
spike.gif
Or perhaps DinkC has odd logic and redink1's example doesn't work, and Striker's example does

Yeah, when you put them on separate lines it works. Multiple commands on the same line don't work nearly as often.
September 26th 2005, 01:35 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Yeah in Dinkc.txt Seth writes the following:
DinkC PARTLY supports multiple commands per line, but later I decided not
to pursue it.. was eating up too much processer time with my slow searches..

So this is a large difference between C and DinkC.