Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP 6.0 variable declares
Message
From
26/05/1998 10:31:20
 
General information
Forum:
Visual FoxPro
Category:
Conferences & events
Miscellaneous
Thread ID:
00101472
Message ID:
00101904
Views:
22
>I am not talking about strong typing. As a matter of fact I am against that. I would like however that before a variable is used to check that it already exists.
>
>With today's complex software, we need as much help from the tools as we can.
>
>It could simply be done as a runtime option. If a variable does not exist, do not create it. It should not cost anymore execution time than how it works now.
>
>Also empty arrays should be allowed. It seems to me silly that they require at least one element.
>
>Costas


I would very much be in favor of strong typing, or at least the option to do so. VB has the "Option Explicit" command to force variables to be defined before they can be referenced. That is exactly what I would want.

I can't tell you how many times a mistyped variable name has crashed a program when I least expected it. Also, in some legacy code I've been working with, no naming conventions were used, and the generic variable name Temp was used to store, in various procedures (and sometimes in the same procedure), a character, an integer, a logical, and a memo field. Sloppy code, to be sure, and with the potential for disastrous results.

Declare your variables as integer, character, numeric, boolean, etc, at the berginning of your program/procedure/function/method. It makes debugging so much easier, and guarantees that you don't accidentally move the character "123" into a variable that will be used for integer calculations. If you don't want to explicitly type your variables ahead of time (why not, I'm not sure, but I'm sure people have their reasons), then have something similar to the Variant datatype in VB. You still get the flexibility, and you ensure your spelling is correct.

As far as empty arrays, it might be nice if they are initialized with a null. (For that matter, in my above variable declaration strategy, have all declared variables, regardless of type, be initialized with null.) You would still have to check element (1,1), but it could be worse...at least our arrays start with element 1, instead of element 0.

Maybe in VFP 7.0, the hypothethical VFP 8.0, or the mythological Visual FoxBasic...

Bill
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform