Quick question,
I'm not an expert with how .NET compiles, but I was wondering if there exists a feature anything like traditional C++ macros (#include, #whatever) whereby a function could be called with syntax not unlike a regular call, but allow the function code to be literally copied during compile time into an inline routine, thus removing repeated function calls.
One could re-use code and get the speed advantage of hard-coding. Updates to the routine would not require modifying multiple instances of identicly hard-coded routines.
e.g.
inline function myInlineFunction
{
//do lots of CPU intensive things here...
System.Console.Writeline("test function " + scopeVar + "\n");
System.Console.Writeline("test function " + scopeVar + "\n");
System.Console.Writeline("test function " + scopeVar + "\n");
System.Console.Writeline("test function " + scopeVar + "\n");
}//end of myInlineFunction
//meanwhile back at the ranch...
Class1
{
static void Main()
{
int scopeVar = 1;
ulong max_count = 99999999;
System.out.writeline("Welcome to my speedy program\n\n");
for (int i = 0; i < max_count; i++)
{
//normally a function call would be used 9999999 times
myInlineFunction; //code is literally pasted here during compile-time
}//end of for
}//end of member Main
}//end of Class1
This kind of routine would not be able to return values, or accept values, and would exist (have access to variables) only within the scope 'this' of where it was called from.
I could see this as a speed enhancement. Does it already exist? If this is a newb question, I appologize in advance.