DougGwyn
Re:Tell HN: C Experts Panel – Ask us anything about C
on Thursday April 16, 2020 @07:29PM (#22894642)
I thought it was strictly one character per 32-bit code.
Anyway, whatever it is called it is what wchar_t should be.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Thursday April 16, 2020 @07:21PM (#22894589)
The argument "0" is not automatically converted to the right type unless there is a prototype in scope. It isn't as important in this case because it is highly likely that the appropriate prototype has been #included, but it is a bigger deal if we're dealing with arguments for a variadic function. Anyway, it's good to be reminded what the declared types are.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Thursday April 16, 2020 @07:12PM (#22894543)
There are several multibyte character manipulations that are easier if there is a uniform-sized encoding (wchar_t).
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @06:30PM (#22872276)
Why would the utilities not handle unicode searching? Unicode characters match properly, the null terminator works the same, and non-ANSI codes are just one or more random 8-bit values which can be compared, copied, etc.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @06:20PM (#22872197)
In fact I proposed strdup on a few occasions, but it wasn't adopted. It seems that they didn't like for standard library functions to use malloc.
POSIX.1 specifies strdup.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @06:10PM (#22872109)
If you changed UTF-16 to UTF-32 or UCS-4 I'd support it. I think there are already implementations that use the replacement character for all "impossible" codes.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @05:58PM (#22872019)
Why is there a second argument which is not used?
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @05:52PM (#22871959)
There is a Web page I saw a few days ago that does that, probably findable by grepping Wikipedia. Unfortunately I forget its URL.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @05:40PM (#22871820)
I don't think most users of C want things changing underfoot.
Keeping track of all the version combinations is infeasible, especially when you consider that an app and its library packages are likely to have been developed and tested for a variety of environments. To the extent that existing correct code has to be scanned and revised when a new compiler release comes out, one of the primary goals of standardization has failed.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @05:33PM (#22871744)
Code can be non-portable for various reasons, not all of them bad. I just grepped a recent release of DWB and found about 100 uses of isdigit, most of which were not input from random text but rather were used internally, such as "register" names (limited to a specified range). Other packages are likely to have similar usage patterns. I really don't want to have to edit that code just for aesthetics.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @05:24PM (#22871641)
Many antique computers are simulated by SIMH. If you have the corresponding software, you can operate on your desktop a simulated computer's software development system. For example, DEC VAX (VMS or Unix) has a relatively simple and sane assembly language.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @05:15PM (#22871541)
(1) There are several implementations; most are based on Knuth's "boundary tag" algorithms. As to "heap", a stack has one accessible end, a heap is essentially random-accessible. Nothing to do with the heap data structure.
(2) Stack overflow can occur even early within a program. I've campaigned for a requirement that such overflows be caught and integrated into a standard exception handler, to no avail. (3) Why not code your own, so there won't be arguments about it. (4) There are lots of tools for program development, but it's not standardized by WG14. (5) Use wider integer types. (6) Use wider floating representations. (7) Standard C doesn't specify such a facility, but it has occasionally be suggested. (8) There were a lot of books, e.g. on structured system analysis, during the 1970s trying to apply lessons learned. C isn't special in that regard, as many of the big problems don't involve syntax. (9) C++ is now a big language and it takes a lot of work to master its internals.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:57PM (#22871347)
Note that the ABIs cover endianness as well as value range and/or object widths. In general, one needs to have explicit marshaling and unmarshaling functions to map from network octet array and C internal data representation.
Failure to get this right is (or used to be) a common bug for code developed and tested on too few architectures.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:48PM (#22871253)
If you're using parentheses, as has been recommended for decades, there is no problem. Otherwise, it is likely that such a change would adversely impact previously working code. There just isn't a pressing need to change it.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:43PM (#22871183)
Let's assume the types have been corrected.
malloc((size_t)0) behavior is defined by the implementation; there are two choices: (a) always returns a null pointer; or (b) acts like malloc((size_t)1) which can allocate or fail, and if it allocates then the program shall not try to reference anything through the returned non-null pointer.
Now, memset itself is required (among other things) to be given as its first argument a valid pointer to a byte array. In particular, it shall not be a null pointer. Tracking through the conformance requirements, if the malloc call returns a null pointer then the behavior is undefined. Thus, you should not program like this.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:17PM (#22870931)
I thought we had fixed the BSD socket aliasing a long time ago?
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:12PM (#22870873)
"Implementation-defined" is a nuisance, because then you need to add code for all the variations, which also requires a set of standard macros, etc. It is easier and less trouble-prone to just avoid using the currently undefined behavior.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:07PM (#22870823)
You can easily create your own stdc.h include file. Something similar was done on Plan 9.
Note that by including the content of all the headers, you're increasing the chance for collisions with application identifiers. You might consider that more of a benefit than a drawback.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @04:01PM (#22870741)
Yes, I have found it helpful. One nice feature is that it uses a character-terminal interface, not a platform-specific GUI.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @03:58PM (#22870702)
There are a lot of arithmetic conditions for which C could generate special code. There are div_t-related functions for the other direction. I for one would like a good way to obtain, using some Standard C coding pattern, fast "carry" for multiple-precision integer arithmetic.
Several places in support functions, I have coded unusually to avoid wrap-around etc. I bet you could devise something like that for (unsigned) multiplication.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @03:42PM (#22870533)
isdigit is likely to remain, because much existing code does use it (perhaps in different contexts from the one you cited). If you need a different function specification to do something different, it could be added in a future release, but that doesn't mean that we need to force programmers to change their existing code.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @03:37PM (#22870500)
Original standard feature specifications were not meant to obtain a 1-to-1 map from C onto hardware, but we used practical experience to judge what overhead was acceptable for the kinds of processors we had seen or thought were reasonable choices that the architects might make in the not too distant future. If a frequently-executed action had to (for example) check for a special condition every time, the overhead might increase by several percent, depending on the instruction set architecture. So quite often we argued that "if the programmer wants to test for that condition, he can do so, but typically it is a waste of cycles". There are a lot of such trade-offs; maybe we should write a paper or book on this topic.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @03:21PM (#22870291)
I think that's right. These days, much of the discussion occurs through study subgroups (like the floating-point guys) and the committee e-mailing list.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @03:11PM (#22870176)
In general, the committee accepts what we used to call "defect reports" (now something like "requests for improvement"), assigns them "WG14 series" sequence numbers, and upon requests for "floor time" schedules meeting discussions. Occasional votes are taken, which might trigger modifications to the draft standard. At some point, the committee decides that the updated draft standard is ready for public review, and the various national representatives deal with review comments. All this starts with proposal documents in "WG14 series" form.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @03:00PM (#22870034)
The rule is: If you want your program to conform to the C Standard, then (among other things) your program must not cause any case of undefined behavior. Thus, if you can arrange so that instances of UB will not occur, it doesn't matter that identical code under different circumstances could fail to conform. The safest thing is to make sure that UB cannot be triggered under any circumstances; that is, defensive programming.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @02:51PM (#22869920)
The main editing needed to bring "old C" source code up to snuff using a "modern C" compiler is to make sure that the standard header-defined types are used. No more assuming that a lot of things are, by default, int type. A second, related editing pass is to make sure all functions are declared as prototypes, no longer K&R style; K&R style is slated to be deprecated by the next version of the Standard. (There are some rare uses for non-prototyped functions, but evidently the committee thinks there is more benefit in forcing prototypes.)
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @02:33PM (#22869672)
There is little that the C Standards group can do about it. One idea is to write a C Standards conformance into contracts. When I was in the government we often did that, but it still wasn't enough clout.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @02:29PM (#22869627)
Back from lunch. Any West Coasters?
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @12:45PM (#22868193)
I thought it would be best to standardize just a single thread, which should be the basic unit to be embedded in a good parallel-processing model. However, others prevailed.
Re:Tell HN: C Experts Panel – Ask us anything about C
on Tuesday April 14, 2020 @12:40PM (#22868106)
Yes, I meant the 31-bit code point value (more than 16, anyway). It is the most useful width for doing things with wide characters.