Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
#DEFINE / Arrays
Message
De
01/06/1999 21:04:45
 
 
À
01/06/1999 20:52:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00223511
Message ID:
00225180
Vues:
13
>>>aPrivArray = 'Bar'
>>
>>Now, aPrivArray becomes a char string variable, not array.
>>
>
>No, this assigns 'Bar' to all elements of the array aPrivArray. Try:
>
>DISPLAY MEMO LIKE aPrivArray

Nope. I always said that the simplest programs are the best tests. :)
So, try the following:

private aPrivArray[2]
aPrivArray = 'Bar'
display memo like aPrivArray && Display: Priv C "Bar"
? "aPrivArray Type:", type("aPrivArray") && Display: C
? "aPrivArray[1] Type:", type("aPrivArray[1]") && Display: U

and you'll see the result of the assignment.

>What =really= happens is that the scope of the referenced array is hidden; a PRIVATe, which would be visible downward, scopes as a local. Unfortunately, so does a PUBLIC. The redimension would 'carry up' the chain - when the funtion returns, the array passed by reference has beeen redimensioned 'upwards' as a side-effect. The NTI entry becomes associated with a new value entry, and the old value entry is toast. The old NTI entry is hidden for the time that the parameter is visible, and by using an LPARAMETER, the PUBLIC or PRIVATE array disappears beneath the scope of the function call.

... Did you try my sample code? I tried yours and, at the first sight, I was tempted to extract the same conclusion as you did. But, since from my experience the conclusion is wrong... :)

Simplify your program to the strictly necessary lines of code, and the real behavior becomes obvious. Or am I blind this evening? :)) I wouldn't be surprised given the day I had today. :)

>I do, however, believe that the side effects of pass by reference in thsi case can and do lead to an error that's really tough to debug, and not teribly descriptive; VFP assumes that the public array reference in the function is a function call because the PUBLIC's name is hidden.

I don't see the side effects.

>Yes, but even without the redimension to confuse issues, the public reference in:
>
>? aRefArray[1,1], aPubArray[1,1]
>
>in the function call breaks things. The reDIMENSION is there only to cause some added confusion in the name resolution, by breaking the link between the value hidden and associated directly with the PUBLIC and the revised value definition in the pass-by-reference array.

See my other message.

Vlad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform