PDA

View Full Version : Gotchas.



lodi
11-09-2009, 08:19 PM
I learned today that putting the opening brace on the same line as the 'defaultproperties' keyword...



defaultproperties {
...
}


as opposed to



defaultproperties
{
...
}


... will silently ignore anything in that section (thanks NightRyder!) But this indentation style doesn't seem to affect anything else I've tried.

e.g.


function PawnDied(Pawn inPawn) {
...
}


and



function PawnDied(Pawn inPawn)
{
...
}


both work.

Anyone find any other subtle bugs or inconsistencies that have caught them off guard?

IceIYIaN
11-09-2009, 08:46 PM
I would suggest
BlahBlah
{

}

Cause it's easier to Copy/Paste and for a lot of people easier to look at (:

chrustec
11-09-2009, 11:43 PM
Yeah agreed I find that using this

function blah(Pawn inPawn)
{
........
}

is far more clearer to read than this:

function blah(Pawn inPawn){
........
}

but thats just me :)

Blade[UG]
11-10-2009, 01:44 AM
Hmm. Really? That's a pretty annoying bug. My standard code style for years and years has been to put the open brace on the same line as the start of the block, even though tons of people i know frown on it.. that just annoys me.

kumo
11-10-2009, 05:51 AM
THANK YOU!

This has just wasted about 2 hours of my life. So glad I saw this.

Personally I have never seen the point of:

method()
{
stuff
}

It just seems like a waste of lines.

elmuerte
11-10-2009, 07:24 AM
defaultproperties are "special", it's not part of the script compiler. In fact, the defaultproperties block is stripped from the code before it is fed to the compiler. There used to be even more inconsistencies between the defaultproperties block and unrealscript.

immortius
11-10-2009, 07:38 AM
I guess something that may or may not be a gotcha (I consider it handy, but you wouldn't want to find it accidentally):

In unreal script (at least last I checked), unlike in any other language I've come across, it is possible to nest comment blocks.

i.e. This is valid


function DoStuff
{
/* Some garbage
/* More garbage
*/ Some more garbage
*/
}

NightRyder
11-10-2009, 08:09 AM
lodi: np. I only found that because I told someone something didn't work, and then it did.. so I gave an o_O face and had to investigate.

Ah.. yea that's what I get for wanting to save lines. I guess that could fall under what my teacher calls the 2-step Don't Do It method. (which refers to optimizing.. 1-don't do it. 2-don't do it yet.)

immortius: hahahah. That is good to know. Although, I'm not sure if that will really make it easier or harder to use because I usually don't use /* */, and prefer // in front of each line (yay IDE's making that easy). I guess (hope) that doesn't also work for braces.. can you imagine the issues that would cause?

Malevol3nt
11-10-2009, 10:39 AM
Funny, I use a combination of both. When I'm defining a data-type, such as a structure I use:


struct DataThing {
string SVal;
int iVal;
}


but for functions I use the braces the other way:



int addition (int a, int b)
{
int r;
r=a+b;
return (r);
}


Everyone has their own style I guess.