Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Array Property
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Divers
Thread ID:
00089579
Message ID:
00089700
Vues:
32
Vlad,

I think you got my point wrong. If round brackets have been the norm for
both Fox Software and Microsoft, then it is perfectly fine to use
them.

Out of the three examples you have mentioned none of them proves
the point that it is bad to use brackets. One of them merely
shows that, as with all other aspects of Visual FoxPro, there
may be bugs in one or two array functions in FP for Unix, just
like there were many bugs with table buffering and grid control
in VFP 3. That's all that example proves. As with the others,
using an array that has the same name as a FoxPro function is
simply bad coding.


I have used Cobol, PL/1, Pascal, Fortran, FoxPro, and C, and it is
only in C that the square bracket is the norm for arrays; in all
the others round brackets are used by the majority of coders and
by the language manufacturers.

What has happened with FoxPro since version 2.0 is that Microsoft
has enhanced the language so that programmers can use round and
square brackets interchangeably, which is good.

No good programmer could possibly confuse an array with a function
when looking at a someone else's code, however I do agree that using
square brackets for arrays and round brackets for functions would make
the differentiation more obvious and provide an immediately noticeable enhancement when looking at someone's code.

And to finish : did you actually realise that you can use square
brackets for functions as well ?!!! Well, well ....

Michel.

================== Your original message follows =============
>Can you explain, I've been using round brackets with arrays since
>FoxPro 2.0 without a single problem. And our functions have been
>running on Visual FoxPro since November last year without problems
>either.

Just because you never run into problems with it, it doesn't mean it's good to be used. :)

>More to the point, if you look at the VFP 5.0a Help, Microsoft
>uses round brackets absolutely everywhere that they mention
>arrays, starting with the DIMENSION/DECLARE commands (Examples
>section).

Just because MS is doing something, it doesn't mean it's good and should be followed. :) In this
case and IMO, this is a very bad example and it shouldn't be followed. BTW, the VFP help is pretty
good IMO, but the examples are not so good. In fact, there are several examples that can go
directly into a "What shouldn't be done in VFP" book... :( Don't ask me now to tell you exactly which
are those examples... :) I never kept a list of them! But one that I remember now is for AINS(). They
give an example on how to use AINS(), but in that example AINS is completly useless...

Unfortunately, VFP is an exceptional tool with an average documentation and bad examples and
wizards. Again, this is my opinion...

>So, aside from your own conventions, what bug are
>you exactly referring to ?

I am not referring to a VFP bug. I said that one can run into nasty bugs because of using () instead
of [] for arrays. These bugs are all application specific bugs. The most common one is when there
are a function and an array with the same name in the same app. In some situations, VFP can't
decide that is about an array and it calls the function.

Another bug I had to trace into an app written by somebody else was when FP for Unix "decided"
that it cannot find a function. The function name was in fact an array name and changing the () with
[] solved the problem. This type of bug is very rare and I've seen it only twice. Also, it's not very
difficult to be found. The other one is very difficult and may take some time to be found, especially
when the function returns values possible to be stored in the array with the same name.

Besides all these, there is a readability reason: if you use consequently [] for arrays, you'll always
know that it's an array and not a function. Also, any other FP programmer will know at a glance that
it's an array. Otherwise, for someone that doesn't know the app/framework, it's almost impossible
to say if it's a function or array. Am I right? :)

Considering all these and the fact that there is no good reason to use () for arrays, I strongly
recommend [] for arrays. Beyond this recommendation... everyone can use anything he/she wants
in his/her apps. :)

But if it's about posting code on UT or newsgroups... I really like to see arrays with []. This way I can
know immediately what is all about...

Vlad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform