I read a bit in the sources, trying to get my footing back in Dotnet and xSharp.
a) If I am not mistaken, the code for the vfp "evaluate()" is in
/Runtime/XSharp.RT/Functions/Macro.Prg
as it has the NeedsAccessToLocals(TRUE) qualifier Robert mentioned when discussing non-function variable access seen also in Type().
Code: Select all
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/evaluate/*" />
/// <seealso cref="NeedsAccessToLocalsAttribute" />
[NeedsAccessToLocals(TRUE)];
FUNCTION Evaluate(cString AS STRING) AS USUAL
RETURN Evaluate(cString, TRUE)
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/evaluate/*" />
/// <param name="lAllowSingleQuotes">Should single quotes be allowed as string delimiters.</param>
/// <seealso cref="NeedsAccessToLocalsAttribute" />
[NeedsAccessToLocals(TRUE)];
FUNCTION Evaluate(cString AS STRING, lAllowSingleQuotes AS LOGIC) AS USUAL
LOCAL oMacro AS XSharp._Codeblock
LOCAL uRes AS USUAL
oMacro := MCompile(cString, lAllowSingleQuotes)
IF oMacro != NULL_OBJECT .AND. ! oMacro:IsBlock
uRes := oMacro:EvalBlock()
ELSE
// strange but evaluate on a codeblock returns the block in stead of evaluating it
uRes := oMacro
ENDIF
RETURN uRes
C# compiler is capable to work with optional / default parameters, IIRC xSharp can do the same?
If the function signature defines 2nd Parameter as optional, defaulting to TRUE,
the single parameter evaluate() is not needed for code from vfp sources and does not cause NeedsAccessToLocals(TRUE) to fire twice on each call. Should result in better performance?
b) [The Vfp compatibility list](https://www.xsharp.eu/itm-help/foxpro-c ... ility-list) from 9/2023 lists GetPEM() under "Functions that won't be supported". Please move into "partially supported (more or less)" and support GetPEM only for "P", as this is the best way to access a property in vfp if object handle is present and (list of) name(s) need to be accessed.
Attached is micro-benchmarking vfp code which compares the runtimes of GetPEM() to 2 versions of Evaluate() and Macroexpansion when the always time for scaffolding the test is eliminated.
This function also is a real function, no need for NeedsAccessToLocals(TRUE).
Untested:
Code: Select all
FUNCTION GetPEM(oObj as USUAL, cString AS STRING) AS USUAL
///try
RETURN oObj.&cString
/// catch
/// throw Exception ("Property " + m.cString + " not found")
///endtryc) really no change in vfp compatibility list from 9/23? Sounds sad...
regards
thomas

