On the other hand, C's treatment of arrays in general (not just strings) has unfortunate implications both for optimization and for future extensions. The prevalence of pointers in C programs, whether those declared explicitly or arising from arrays, means that optimizers must be cautious, and must use careful dataflow techniques to achieve good results. Sophisticated compilers can understand what most pointers can p…
Well, Ada forces aliasing to be explicitly requested. You see an example here https://gcc.gnu.org/onlinedocs/gnat_ugn/Aliased-Variables-an... To use C vocabulary, Ada always assumes restrict unless you make use of aliased , and it is a compile error to handle it otherwise.
The Development of the C Language
21–24 of 24 posts
Re: The Development of the C Language
#22I love stories like this. All the history behind a very young but rich science. For example I always assumed C came from a strong typing background and its premises was always about being portable. Neither of them are true.
Re: The Development of the C Language
#23Earlier quoted context omitted.
Well, Ada forces aliasing to be explicitly requested. You see an example here https://gcc.gnu.org/onlinedocs/gnat_ugn/Aliased-Variables-an... To use C vocabulary, Ada always assumes restrict unless you make use of aliased , and it is a compile error to handle it otherwise.
Wow Ada syntax is not what I'm used to! This is interesting; it seems like a very simple solution to make the problem less widespread. It is still on you though to use the correct version of the equivalents of memcpy() and memmove() though?
It has all the modern goodies in it, OOP, interfaces, contracts alongside type safety.
Then if you really care about high integrity systems, there is its brother SPARK, which is a hardened version of Ada, the latest revision being from 2014.
Regarding calling memcpy() and memmove(), the compilers should be able to produce the right kind of code.
Now if you really mean the C functions, the aliasing declaration should be part of declaration.
Not sure what is the current state of Ada's POSIX specification.
Re: The Development of the C Language
#24On the other hand, C's treatment of arrays in general (not just strings) has unfortunate implications both for optimization and for future extensions. The prevalence of pointers in C programs, whether those declared explicitly or arising from arrays, means that optimizers must be cautious, and must use careful dataflow techniques to achieve good results. Sophisticated compilers can understand what most pointers can p…
> My question to HN is: do any languages that really emphasize pointers and iterators over arrays and indices have a non-cumbersome way of telling the compiler when no aliasing is expected? Rust has this concept baked into the language: any mutable reference is statically guaranteed to not alias anything else that is accessible. Non-mutable references can alias each other, but I don't think there are any optimization…
I'm interested in any language innovations that have a smooth, suave feature for this. Rust changes the default, but in some sense its not an absolute improvement; where C bluntly assumes memmove(), Rust bluntly applies memcpy().