Initializing local properties

David Bovill david.bovill at gmail.com
Wed Apr 15 11:33:06 EDT 2009


2009/4/15 Richard Gaskin <ambassador at fourthworld.com>

>
> There's a request for this in the RQCC:
> <http://quality.runrev.com/qacenter/show_bug.cgi?id=1241>


Voted for - would be great if others could!


Why are globals so unloved?
>
> Most programming languages support them so they can be accessed globally.
>  If you need global access, why not use a global?


True - some of my allergy to them is not rational :) In this case I'm trying
to speed up the script so the behaviors of the "view library" I'm working
on. I have about 50 views at the moment, which I'm going through and
tidying. Each "view" has a complex geometry / behavior script which refers
to controls within the view - on average maybe 4 controls for each view. I'd
expect the library will eventually have a few hundred widgets in - using
globals would mean creating say 800 global variables or I guess an array
with 800 entries. Then I'd have to make sure there were no name clashes...
etc

But most of all it does not solve the problem of initializing the variables.
I don't want to create a complex mechanism that loads and maintains this
stuff for every script, writing preopen card handlers and getting errors
every time I miss one out. I want to define them in the context of the only
place they are used - the script of the behavior - and I want them to be
initialised when and only they are used - simply by me defining them in the
script.



More information about the use-livecode mailing list