Quantcast
Viewing latest article 1
Browse Latest Browse All 222

Answer by Peter - Reinstate Monica for Why did the POSIX function strcasecmp() get such weird name?

We talk about an environment in which the system function to create a file is named creat, for heaven's sake; while it is the main error in the Unix design Ken Thompson would fix if he could do it all over again, short names were the prevailing motto as witnessed by ls, cd, and, yes, strcmp. Part of that surely is rooted in the literal paper teletypes (ever wondered where /dev/tty comes from?) used for input, or in the 4 kB of RAM and a printer that prints 10 characters per second. If you can make your source code a few percent smaller by omitting the carriage return or having short function names, you did that.

And if there is an existing function for case sensitive comparisons named strcmp(), there is little doubt what strcasecmp() does. As standard library functions go it is very long already, for example it is longer than any in string.h. I bet you the author was tempted to name it strccmp() or at least strcascmp() but remembered Thompson's regret ;-).


Viewing latest article 1
Browse Latest Browse All 222

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>