variable declaration
Posted: Fri Oct 25, 2019 2:01 pm
Robert has clearly has a point if going strictly by the Help Docs, where Type() and Eval() are listed as functions: If they were typical functions, at the moment they are in their own scope and access the string with the name of the local var, they should be unable to access it.OTOH "Command" is signified normally by not returning a result. From the top of my head I remember 2 vfp "commands" going against that directive: Store ... To and Do Form ... To, both modifying the variable( s)/properties pointed to. Perhaps a separate hermaphrodite between category should be defined for "executing in same scope/stacklevel and changing a result" and group Store To, Do Form To, Type() and Eval thereunder. Sounds more technical than "hanging on to a scope and playing billards with it"António Lopes wrote: I don't think TYPE() treats local variables differently as a special case. It just evaluates its argument at run time as a VFP expression and returns its type. As a compiler problem/use case, probably it falls in the same category of EVALUATE() (as Thomas mentioned) and macro expansion, I would dare to say from the (very far) outside...
The "functional" way of calling is necessitated by option of "levelled" calls, which would in normal function result in stacklevel differences > 1, but perhaps way of executing a command [GetType,GetEval] on an expression with resultstorage this can be tackled. Python and Javascript are similarly freewheeling as vfp, but those with static compile targets have less freedom in that area - C# calls it evaluating expressions and in Java myriads of attempts to slice that problem can be found.
As often as type() and evaluate() are used, I'd hate to see a "visible namespace" to be built each time just to run an eval() or type()