What is this noalias thing Dennis Ritchie is railing about ?

  • Thread starter Spiros Bousbouras
  • Start date
M

Malcolm McLean

James Dow Allen said:
Here's the relevant Dennis Ritchie Usenet post:
//groups.google.com/group/comp.lang.c/msg/991b9116ffa83c60?
dmode=source

Although Dennis obviously disapproved of
"broken" proposals, his comment goes further:

Dennis' comment seems like a good antidote
to the frequently-heard assumption that
adding a feature to a language automatically
makes it better.
Mr Ritchie has desinged a successful language whilst the committees has
proposed an unsuccessful standard, so I've give his opinion more weight.

const would have been a good idea, had it been designed in right from the
start of the language. However it doesn't fit C as she is spoke. C++ has
even added a "mutable" keyword. All problems can be solved by adding another
layer of indirection.

On "volatile" I think he is wrong. It doesn't have a place in programs
written in pure C, of course. However I cannot think of any better solution
to the problems of threads and interrupt routines.
 
M

Malcolm McLean

Wow, what a pig's breakfast! I also find "restrict" is often a useful
name for a variable - one more reason to stick with C90!
I propose a new syntax

)ptr(

a restricted pointer.
 
C

Charlie Gordon

Richard Bos said:
Why a pig's breakfast? This allows restrict to specify exactly what was
written in words in the previous Standard: that the two pointers to
memcpy() must not point to overlapping areas, and that those to
memmove() may. This is actually the most useful application of restrict
I've found in the Standard.

This wording is not precise enough: you can pass pointers to the same object
to memcpy, but the areas accessed through these pointers by memcpy should
not overlap.

Using the restrict keyword on the function declaration is just a weak hint
the the programmer about potential constraints on the arguments. It does
not give any information to the compiler.

Using restrict on the function definition allows the compiler to produce
optimized code for instance with fewer memory loads: anything accessed
through a restricted pointer is guaranteed by the programmer to not have
been modified through another pointer within the same scope. This guarantee
is a consequence of documented constraints that callers of the function must
fulfill.
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top