Keep in mind that a static variable, once created, could not be changed by 
_any_ process. If it could be changed by nonpreemptive processes, then it isn’t 
much different than a normal IP variable in the sense that even reading it 
would require an OS level lock of some type. But I still think they would be 
useful and solve a whole swath of the challenges we are considering.

I’m not sure what character(s) would be used to preface a static variable. I 
was originally thinking they would look the same as they currently are, but 
might render in a different color in the method editor. In any case, I would 
hope it would be done with the idea that locals and process variables could 
also be static.

I’ve been thinking about how a static variable could be instantiated. Think of 
an array, for example. By definition, once it is declared and an element is 
added, it can’t be changed any more, so you couldn’t add more elements. Maybe 
the best way is to create a local array and then the mechanism for declaring a 
static array would also take an argument to the local array which it would copy 
during instantiation. C_Objects could work in a similar way.

I suppose we would have to ensure our code always instantiated all possible 
static variables very early. You wouldn’t want any code to try to access an 
uninstantiated static variable!

--
Cannon Smith
Synergy Farm Solutions Inc.
Hill Spring, AB Canada
403-626-3236
<[email protected]>
<www.synergyfarmsolutions.com>


> On Nov 1, 2016, at 5:51 PM, Tim Nevels <[email protected]> wrote:
> 
> Static variables, interesting idea. Special new variable table that is 
> optimize to work with preemptive methods. Static variables are read only from 
> a preemptive method. You can use them in non-preemptive processes. They work 
> basically just like IP variables, except they are thread safe when referenced 
> in preemptive processes. Maybe the only way to set a static variable value 
> would be to do it in a non-preemptive method. Just stream of consciousness 
> thinking here...
> 
> What would the variable name prefix be for static variables: ^officeCode_t or 
> *officeCode_t. or #officeCode_t? Then you could use the “Rename” command in 
> design to quickly update all your code with the new variable name. 
> 
> Or would you change compiler directives and add the infamous “*” parameter to 
> indicate this is a static variable C_TEXT(officeCode_t;*).
> 
> This might be the feature request that Tony really wants and needs. Heck, now 
> that I think about it, I want this too!
> 

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to