I don't need to test my programs. I have an error-correcting modem.

Difference between revisions of "UnrealScript Feature Recommendations"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m
m (Block Scope variable definitions)
Line 9: Line 9:
 
foreach ObjArray(Obj)
 
foreach ObjArray(Obj)
 
{
 
{
//do something here
 
 
//Obj is accessible here
 
//Obj is accessible here
 
}
 
}
//Obj is not defined and inaccessible in this scope
+
//Obj is defined and inaccessible in this scope
 
}</uscript>
 
}</uscript>
  
Line 20: Line 19:
 
foreach ObjArray(local Object Obj)
 
foreach ObjArray(local Object Obj)
 
{
 
{
//do something here
+
//Obj is accessible here
 
}
 
}
 +
//Obj is not defined and inaccessible in this scope
 
}</uscript>
 
}</uscript>
 
'''The local keyword could be replaced with var, block or just omitted entirely. Similarly this would work for any type as in the following:'''<uscript>
 
'''The local keyword could be replaced with var, block or just omitted entirely. Similarly this would work for any type as in the following:'''<uscript>
Line 28: Line 28:
 
foreach ObjArray(var Object Obj, var int i)
 
foreach ObjArray(var Object Obj, var int i)
 
{
 
{
//do something here
 
 
//Obj and i are only accessible here
 
//Obj and i are only accessible here
 
}
 
}
Line 66: Line 65:
 
}
 
}
 
}</uscript>
 
}</uscript>
 +
 
==Triplet type==
 
==Triplet type==
 
A type that can only be one of the following, constructed from 2 boolean types, one which denoted the value of either 0 or 1 and the other which denotes the sign being a negative or positive. There is infact a possibility for a negative zero.
 
A type that can only be one of the following, constructed from 2 boolean types, one which denoted the value of either 0 or 1 and the other which denotes the sign being a negative or positive. There is infact a possibility for a negative zero.

Revision as of 23:29, 29 April 2010

Unreal Script Feature Recommendations

Block Scope variable definitions

This:

function NoBlockScope()
{
	local Object Obj;
 
	foreach ObjArray(Obj)
	{
		//Obj is accessible here
	}
	//Obj is defined and inaccessible in this scope
}

Would become:

function BlockScope()
{
	foreach ObjArray(local Object Obj)
	{
		//Obj is accessible here
	}
	//Obj is not defined and inaccessible in this scope
}

The local keyword could be replaced with var, block or just omitted entirely. Similarly this would work for any type as in the following:

function BlockScopeTwo()
{
	foreach ObjArray(var Object Obj, var int i)
	{
		//Obj and i are only accessible here
	}
	//Obj and i are not defined and inaccessible in this scope
}

Default variable assignment

This:

function bool CheckReplacement(Actor Other)
{
	local Controller C;
 
	C = Controller(Other);
 
	if(C != None)
	{
		//do something here
	}
}

Would become:

function bool CheckReplacement(Actor Other)
{
	local Controller C = Controller(Other);
 
	if(C != None)
	{
		//do something here
	}
}

The following example is of both block scope and default variable assignment:

function BlockScopeThree()
{
	for(local int i = 0; i < A.length; ++i)
	{
		//do something here
	}
}

Triplet type

A type that can only be one of the following, constructed from 2 boolean types, one which denoted the value of either 0 or 1 and the other which denotes the sign being a negative or positive. There is infact a possibility for a negative zero.

-1,0,1

Updates to normal()

Using the aforementioned Triplet type one can construct a truple which can be used as a unit vector. This way input into the normal() would be a type conversion and allow for a more correct literal.

<=> Operator

With this type its possible to implement this binary relationship operator Space Ship Operator as in perl, ruby and groovy programming languages.