开发者

Why isn't regular expressions part of ISO C99

开发者 https://www.devze.com 2023-01-07 18:07 出处:网络
Everyone knows how awesome C language is and how much it sucks in text processing tasks. Giventhese facts. Regex definitely must be part of 开发者_如何学编程ISO C. But it isn\'t. I don\'t understand w

Everyone knows how awesome C language is and how much it sucks in text processing tasks. Given these facts. Regex definitely must be part of 开发者_如何学编程ISO C. But it isn't. I don't understand why? Are there people who think its not essential?


Regular Expressions don't belong in the C language proper any more than a sound library, a graphics library, or an encryption library does. Doing so would reduce the general purpose nature of the language and greatly inhibit its use as a small and efficient embedded language.

The philosophy of C was to have a very small and efficient language keyword set with standardized libraries for the next layer of functionality. Since things like regex, graphics, sound, encryption, etc. don't have a single platform or standard they don't fit in with the standard C library.

They fit best as user libraries which they currently are.


Regex is defined as part of IEEE Std 1003.1:2001 (POSIX)

Here's a handly list of which headers are in which standard:

http://www.schweikhardt.net/identifiers.html


Because it is a library feature that would require standardizing on one of the regex languages. Standard bodies are commitee driven, not an easy task.

This document explains the rationalization of the standard: http://www.open-std.org/jtc1/sc22/wg14/www/docs/C99RationaleV5.10.pdf which might clarify why.
Another reason explained in the doc. is to keep the language simple.

There are quite a few downloads available, just use one.


Because regexes are not essential to a programming language. Handy? Yes, very much so, when you need them. Essential? No way.

Web developers will naturally consider regexes to be an essential feature of a language because they have to validate all that HTML form data. Developers whose experience is always with one of a few big-name relational database servers will consider SQL support to be essential. Those working in the scientific domain will require support for "big numbers" or tensors. GUI developers think a built-in GUI toolkit is essential. Some folks deal with XML all day and consider XML support to be essential.... etc. you get the idea. This list of "essentials" can get pretty big, and languages like Java have certainly taken the "kitchen sink" approach to their massive standard libraries. I appreciate that C is not a kitchen sink language in that sense.

Be careful not to assume that your favorite language feature is an essential feature for everyone else.


The point of C is to be small yet powerful. Since regular expressions are typically a large and complex topic, it belongs in a library. It is too bad though that the C committee doesn't "sponser" some well written, standard C, algorithms/data structure libraries. There is a plethora of them out there. I tend to stick with GNU "sponsored" libs whenever I can since they are available for most platforms even if they aren't necessarily the easiest or most efficient to use. They do strike a nice balance.

0

精彩评论

暂无评论...
验证码 换一张
取 消