Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can someone explain why macro needs to have 2 dots?
Message
De
20/02/2007 10:15:42
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
20/02/2007 10:03:27
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01196999
Message ID:
01197299
Vues:
12
>>STORE "Dragan" TO m.lcName is obvious.
>>m.lcName = "Dragan" is slightly less obvious.
>
>Less than slightly - most of us use STORE only when multiple variables need to get the same value, or when it's a Store To (nameExpression).
>
>>lcCmd = "STORE 'Dragan' to m.lcName"
>>*lots of code.
>>*lots of code.
>>*lots of code.
>>*lots of code.
>>&lcCmd.
>>
>>Is far less obvious but may be necessary for the program.
>
>Anything that has lots of code between the location where it's defined and the place where it's actually used will be not obvious and will border on convoluted.
>
>>GETPEM returning an object - is purely a performance trick. It isn't necessary.
>
>Sure, that's why it exists, as just a trick so we can have fun discussing it. Also Scan/Endscan isn't necessary - the do while !eof("myalias")...skip in myalias...enddo works just fine.
>
>I see it as a better way, a simple elegant function which replaces the clumsy macro and/or eval() ways of doing the same thing. We're just used to the latter because we didn't have getpem() in earlier versions. Don't know how far into the past should I go, I tried VFP7 and VFP6 and getpem() existed there and it did return an object. It may only be because we didn't think about this until last year or so, when Fabio came up with this use of the function.
>
>But that's just a matter of habit - and while I may be hard with some of my other habits, I'm quite ready to change my programming habits with every job. This is just elegant and I like it.
>
>>Normally I want every iota of performance. GetPem took .289 seconds and eval took .380, but there's more to consider such as maintainability and readability. Code shouldn't be a puzzle.
>
>What's puzzling in
>
>
loControl=getpem(thisform, m.lcCtrlName)
>
>>It is not documented, it is not even indicated from the function name that it will return an object contained in another object. Maybe it should be called GetPOEM. :)
>>
>>m.luSomething = getpem(THISFORM,"iuSomething")
>>
>>Please tell me exactly what that code does. Would you agree that if you can't, it cannot be called "readable"? How many people can get it correct? You'd probably be able to figure it out from context, but that takes extra time.
>
>Bad naming can throw you off and make anything unreadable. Try to convince me that
>
>
>m.lcSomething="iuSomething"
>m.luSomething=thisform.&lcSomething.
>
>is more readable than the getpem() version.

I can't. :) I will try to remember to use getpem! :)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform