What is the difference between Symbol() and _Symbol

What is difference between Symbol() and _Symbol? Any help would be highly appreciated.

First is a function call, second is a predefined variable. Both give the same extract string.

In general, which one is faster?

Does their execution time difference?

void Func( const string& ) {}

void OnStart()
{
  Func(Symbol()); // ERROR: 'Symbol' - parameter passed as reference, variable expected
  Func(_Symbol);  // OK   
}

Faster is to use _Symbol because it is a definition.

Symbol() is a function, so it has to be executed to retrieve the symbol name every time it is called.

Your code is returning error because your Func() definition expects a CONST string. So it only accepts Static parameters. And you cannot pass a function return to it.

Either modify it removing CONST so you can pass Symbol() to it as a parameter. Or use _Symbol which is faster and ALSO IS a Static Variable :wink:

thanks elaviste1k very good explanation

Actually I think there’s no difference in speed, it gets sort of optimized during compilation.