[DGD] DGD and the static keyword

Felix A. Croes felix at dworkin.nl
Tue Apr 15 16:16:03 CEST 2003


Noah Gibbs <noah_gibbs at yahoo.com> wrote:

> --- "Felix A. Croes" <felix at dworkin.nl> wrote:
> > > [... static locals ...]
> > 
> > Supposing that it would be, what do you expect
> > static to mean in that context?  I'm curious.
>
>   I'd guess that, like in C/C++, it would mean
> "global, persistent, file-scope", and like static in
> LPC, would mean "not saved by save_object".
>   But the feature I'm documenting is actually the
> "static" keyword, so it's not that I needed any
> specific functionality.  I just wanted to document
> what happened if you tried to declare a static local.

Such static local variables could be made to fit into LPC, but they
wouldn't make much sense given LPC's object orientation.  So I am
glad that LPC doesn't have them, and also that you don't have a need
for them.

As a keyword, "static" doesn't make much sense in LPC.  In C, I
assume that it evolved in something like the following manner:
first there were static variables in functions, where "static" had
the meaning "non-automatic, non-volatile".  Later it was given the
broader meaning, for variables, of "a non-automatic variable in
the namespace of the smallest enclosing scope".  C++ logically extends
this by allowing static variables in classes.  For functions, static
as "in the namespace of the source file scope" was copied from
variables.

In LPC, a static function is local to an object, and static
variables have no influence on the object model (though it is static
in the sense of protected from restore_object()-induced volatility).
For DGD, a "local" keyword for functions and no static/save/restore
for variables at all would have been better.  Alas, backward
compatibility.

Regards,
Dworkin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list