linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shriramana Sharma <samjnaa@gmail.com>
To: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: various meanings of static
Date: Sat, 23 Jun 2007 11:38:44 +0530	[thread overview]
Message-ID: <467CB8EC.8080209@gmail.com> (raw)

Hello.

To my thinking, the keyword static is used for four different purposes 
in C++. I will explain this and I request your comments on that:

1. "static" is used in the declarations at file scope of variables and 
functions to make them "local" -- i.e. visible only within that file.

2. "static" is used in the declarations of variables inside functions to 
make them "sticky" -- i.e. not get destroyed when the function is exit. 
They "stick" around.

3. "static" is used in the declarations of variables inside classes to 
make them "classwide" -- i.e. common to all instances of that class, in 
contrast with other member variables which are unique to each instance.

4. "static" is used in the declarations of functions inside classes to 
make them "nothis" -- i.e. not take/require a silent "this" pointer to 
be passed, and hence be able to be called without an instance of that 
class to exist.

I am thinking of using # define-s to use these four words:

local, sticky, classwide, nothis

instead of static in my C++ programs to make them more meaningful. I 
believe that the above four are mutually distinct purposes of the single 
static keyword and whether a future C++ standard disambiguates these 
purposes or not (where I prefer it would) I can even now use these new 
clearer keywords.

Are there any other meanings to static? Or are there any objections to 
the above classification?

Thank you.

Shriramana Sharma.


             reply	other threads:[~2007-06-23  6:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-23  6:08 Shriramana Sharma [this message]
2007-06-23 12:55 ` various meanings of static Darío Mariani
2007-06-23 16:11   ` Glynn Clements
2007-06-24 21:08     ` Pedro de Medeiros
2007-06-25 21:35       ` Glynn Clements
2007-06-25 23:01         ` Pedro de Medeiros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=467CB8EC.8080209@gmail.com \
    --to=samjnaa@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).