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

David Bovill david at openpartnership.net
Fri Jun 29 18:23:15 EDT 2007


Ditto - with one exception - in cases such as repeat loops where a variable
is incremented (silly example):

function countLines someLines
    repeat for each line someLine in someLines
      add 1 to lineCount
    end repeat
    return lineCount
end countLines

I have often found a bug that happens when there is no repeats (ie someLines
is empty) where you get "lineCount" returned and not empty - I used to add:

function countLines someLines
    put empty into someLines
    repeat for each line someLine in someLines
      add 1 to lineCount
    end repeat
    return lineCount
end countLines

but now I:

function countLines someLines
    local someLines
    repeat for each line someLine in someLines
      add 1 to lineCount
    end repeat
    return lineCount
end countLines

Because it's easier to type and makes me take a bit more care :)


On 29/06/07, Chipp Walters <chipp at chipp.com> wrote:
>
> On 6/29/07, Ken Ray <kray at sonsothunder.com> wrote:
> >
> > Personally, my feeling is "whatever works for you, works
> > for you" - by that I mean that over the years of not declaring xTalk
> > variables I have gotten to the point that the likelihood of me making
> > an error in typing a variable is extremely low, so there really is very
> > little benefit and a lot of extra hassle for me to start declaring
> > them. But that's me... Anything that makes the process more efficient
> > is good, IMHO.
>
>
>
> I'm with Ken. I don't declare variables and have spent so many hours
> working
> this way, it's just easier. I rarely if ever find a problem from not
> declaring vars, and the overhead of the typing and visual clutter is a
> nuisance and a time waste to me. Also, I really like using script locals,
> and inserting local vars within handlers would 'look funny' to me as I
> generally think of:
>
> local lColor
>
> as a scriptwide var.
>
> I would expect most of us who've 'grown up' using HyperCard and SuperCard
> aren't as concerned with declaring vars, as those who have worked more
> with
> traditional programming languages.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list