static functions?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Mar 11 19:42:48 UTC 2024


On Monday, March 11, 2024 10:51:48 AM MDT Andy Valencia via Digitalmars-d-
learn wrote:
> On Monday, 11 March 2024 at 16:25:13 UTC, Jonathan M Davis wrote:
> > ...
> > But what exactly static means varies based on the context.
>
> Thank you for the list!  But none of those appear to apply to a
> function defined in the outermost scope of the module.  Is static
> accepted here--but has no actual effect?

There are a number of cases where D allows you to use attributes that are
then ignored when they're used on a symbol where they don't make sense. It's
particularly useful when using the : syntax, since then you can apply an
attribute to the file as a whole without getting a bunch of errors about
that attribute not applying to some of the symbols within the module, but it
does have the downside of making it less obvious when an attribute is
ignored.

> I will look at the privacy controls--thanks again.

Yes, that's what you want if you want to control which symbols are visible
outside the module.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list