printf output

R

Richard Bos

Han from China said:
Certainly having a few extra keywords would be a lot better than
overloading keywords like 'static'.

Oh, come on! It wouldn't be a real C Standard if it didn't define a new
meaning for "static"[1] - that would be like a new adaptation of HHGTTG
which didn't change the story around.

Richard

[1] I suggest a new statement, "switch static" or "static switch", which
does not have fall-through by default. Tongue only half in cheek.
 
T

Tim Rentsch

Keith Thompson said:
Tim Rentsch said:
(e-mail address removed) writes: [...]
One of the key issues for C1X is what new meaning can we come up with
for static? :)

Oh, easy one:

int *static p; // p may point only to objects with static
// or automatic storage duration [1], not to
// objects with allocated storage duration

Of course, we would then also need:

int *!static q; // q may point only to objects with allocated
// storage duration

The benefits to making it easier to know which pointers to
free should be obvious.


[1] Of course not just static storage duration, that would
be too consistent; the other possibilities would be,

int *static !auto x; // for static-only
int *auto y; // for auto only
int * !auto z; // for static or allocated
int * auto !static v; // for automatic or allocated
int * !static !auto w; // pointer may only be NULL

Ah, but you really want to be able to specify any of static, auto, or
allocated storage duration. This gives us the opportunity to combine
yet another re-use of "static" with a new keyword:

int *static x; // static only
int *auto y; // auto only
int *_Allocated z; // allocated only

Apparently I've been out-straight-faced.
 
L

lawrence.jones

Richard Bos said:
Oh, come on! It wouldn't be a real C Standard if it didn't define a new
meaning for "static"[1] - that would be like a new adaptation of HHGTTG
which didn't change the story around.

Well, we did adopt static_assert, but I don't think that counts.
 
R

Richard Bos

Richard Bos said:
Oh, come on! It wouldn't be a real C Standard if it didn't define a new
meaning for "static"[1] - that would be like a new adaptation of HHGTTG
which didn't change the story around.

Well, we did adopt static_assert, but I don't think that counts.

Not really, no. And such a long identifier for something Standard is
ugly. What you should do is make assert() itself behave as
static_assert(), if its first argument is a literal keyword static.
Either like this:

assert(static <expression>);

or like this:

assert(static, <expression>);

Whichever is easier to fit into the new grammar would do fine.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top