implicitVars [Was: Re: Best Practices in Rev development]

Dave dave at looktowindward.com
Fri Jun 29 06:31:31 EDT 2007


On 27 Jun 2007, at 04:17, Kay C Lan wrote:

> On 6/26/07, Alex Tweedly <alex at tweedly.net> wrote:
>>
>> This gives the advantage of a short, clean, easy-to-read script while
>> preserving the advantage of error detection. The need to respond  
>> to such
>> a dialog once per local variable would be (at least for me) a small
>> price to pay - and is certainly much lighter a burden than the  
>> need to
>> add a declaration for each.
>
>
>
> I don't declare variables because I do find that it is easier to  
> use the Var
> Watcher to pick up typos than it is to go through the hassle of all  
> the
> extra typing to declare variables - where I can make extra typos  
> anyway;-(

This is something I can't understand. When I edit code (whatever the  
language) I type the name of the variable once and once only and  
maybe I don't type the whole thing at all. I then use copy/paste to  
paste the variable into where it is being used. For instance, given  
the following:

local myRedValue
local myBlueValue
local myGreenValue
local myAverageValue

To get this, I typed "local myRedValue", then copied that line and  
pasted it back 3 times. Then edited "Red" to "Blue" and "Green" and  
"Average" in the 3 new lines.

Then to get this:

put (myRedValue  + myBlueValue  + myGreenValue) / 3  into myAverageValue

I typed "put ( + + ) / 3 into " and then copied/pasted myRedValue,  
myBlueValue, myGreenValue and myAverageValue into the correct positions.

In fact I used the same technique to do the above!

That's why I can't see the argument that's it's more typing, it  
really isn't, and the bugs that can be caused by not declaring your  
locals are so hard to find that I really can't see any reason not to  
declare them.

All the Best
Dave







More information about the use-livecode mailing list