Il y a quelques minutes encore, étudiant le code contenu dans color_yuv2rgb.c dans xawtv, je ne connaissais pas ce mot-clé du langage C (défini dans la norme C99). Je suis alors tombé sur ce site qui ma fait sourire. L’auteur a rédigé le “contrat” du mot-clé “restrict” pour vulgariser son utilité:
“THE RESTRICT CONTRACT
I, [insert your name], a PROFESSIONAL or AMATEUR [circle one] programmer recognize that there are limits to what a compiler can do. I certify that, to the best of my knowledge, there are no magic elves or monkeys in the compiler which through the forces of fairy dust can always make code faster. I understand that there are some problems for which there is not enough information to solve. I hereby declare that given the opportunity to provide the compiler with sufficient information, perhaps through some key word, I will gladly use said keyword and not bitch and moan about how “the compiler should be doing this for me.”
In this case, I promise that the pointer declared along with the restrict qualifier is not aliased. I certify that writes through this pointer will not effect the values read through any other pointer available in the same context which is also declared as restricted.
* Your agreement to this contract is implied by use of the restrict keyword ;)”