On Saturday, 27 September 2014 at 22:06:00 UTC, H. S. Teoh via Digitalmars-d wrote:
On Sat, Sep 27, 2014 at 02:51:14PM -0700, Walter Bright via Digitalmars-d wrote:
[...]
The only interesting thing is he describes a way that functions (and blocks) can specify what global data they access, and then have the compiler issue errors for accessing any other global data. He has a
way to do that both locally and transitively.

That sounds like PHP. *shudder*


However, the same effect can be achieved via pure annotations and
passing the globals needed by reference as function parameters.
[...]

I'm a fan of grouping related globals into structs with module level instances, and passed by reference to functions that need those specific globals. Truly-global globals are nasty, as are open sets of globals where you either don't access a global, or you (potentially) access *all* globals with no finer access granularity. (I had to debug C code that did that once... boy it was mind-bending when every function call
could potentially arbitrarily change the global state.)


T

A fair amount of HPC code is still written in Fortran with a variables.f90 file that holds most program state as globals. Ick.

Reply via email to