Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Type function is not smart enough
Message
 
 
To
25/10/2002 07:11:25
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00714883
Message ID:
00715374
Views:
22
This message has been marked as a message which has helped to the initial question of the thread.
Hi Hilmar,

Some built-in functions have different return type depending on the parameter passed. For example,
? TYPE([SET("RESOURCE")])  && 'C'
? TYPE([SET("REPROCESS")])  &&  'N'
? TYPE([NVL(Null, DATE())])  && 'D'
? TYPE([NVL(Null, 5)])  && 'N'
So, TYPE() function evaluates its parameter but doesn't look for UDF's for performance reason.


>
>I have seen this problem a few years ago in FoxPro. As to the reasons, I came to the following conclusion:
>
>For a built-in function, VFP (or FoxPro) knows the expected return type. The type can be determined without actually evaluating the function.
>
>For a UDF, there is currently no way to tell VFP that your UDF normally returns such-and-such a type. There is no way for VFP to tell you the type of the expression without actually calling the function. This may have undesirable side-effects: your UDF might do almost anything, or produce an error.
>
>For these reasons, although it is unpleasant not to be able to easily get the type of your expression with type(), I find VFP's behavior perfectly logical.
>
>Regards,
>
>Hilmar.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform