* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * [not found] ` <35E09E76.6773@earthlink.net> @ 1998-08-23 4:00 ` Terry C. Shannon 1998-08-23 4:00 ` Glenn C. Everhart 0 siblings, 1 reply; 69+ messages in thread From: Terry C. Shannon @ 1998-08-23 4:00 UTC (permalink / raw) David J. Dachtera wrote: > > Terry C. Shannon wrote: > > > > Lunux users "get it" loud and clear. I just wonder how Scott McNealy > > will handle it now that he's giving Solaris away! > > IMHO, the part that (tcfka) DEC doesn't seem to "get" is this: The Evil > Empire sold MS-DOS for circa. $100 (+/- whatever) - and now there are > tens of millions of "MS-DOS" (and successor) systems in the world. > (tcfka) DEC charges tens (or hundreds) of $thousands for VMS, and the > numbers of those systems are estimated in the half-million range. > > The billionaire Emperor is hardly hurting for R&D dollars (of course, > they spend far less, also). > > Am I the only one who understands Macro-Economics? > No, hence we see the consolidation of the Unix industry! The care and feeding of ten non-differentiatable (at the end of the day) Unixes costs around $1.5B per annum; the care and feeding of one WNT costs far less. Terry Shannon http://www.acersoft.com (SKD V5N18 just posted there...) ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-23 4:00 ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Terry C. Shannon @ 1998-08-23 4:00 ` Glenn C. Everhart 1998-08-24 4:00 ` Paul Sture 0 siblings, 1 reply; 69+ messages in thread From: Glenn C. Everhart @ 1998-08-23 4:00 UTC (permalink / raw) If the "care" resulted in a robust system... Where we see reported security holes indicating that the kernel isn't checking call args, isn't protecting memory properly, needs to acquire a notion of string size other than location of a null...these are symptoms that the "care" isn't up to VMS standards. Neither is Unix; only the OpenBSD process resembles at all what I saw in VMS engineering for quality. Unix is paying for decades of carelessness. NT is however a newer system, yet we find that trying to build on it is, likewise, building on sand. Sometimes you have no choice BUT to build on sand, but one could wish that better real estate were wider spread.. Terry C. Shannon wrote: > No, hence we see the consolidation of the Unix industry! The care and > feeding of ten non-differentiatable (at the end of the day) Unixes costs > around $1.5B per annum; the care and feeding of one WNT costs far less. > > Terry Shannon > http://www.acersoft.com (SKD V5N18 just posted there...) ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-23 4:00 ` Glenn C. Everhart @ 1998-08-24 4:00 ` Paul Sture 1998-08-25 4:00 ` Gregg E Economou 0 siblings, 1 reply; 69+ messages in thread From: Paul Sture @ 1998-08-24 4:00 UTC (permalink / raw) Glenn C. Everhart wrote: > snip > ... needs to acquire a notion of string size other than location of a > null.... > snip The very first thing that put me off C!!! -- Paul Sture Z�rich paul dot sture at ubs dot com ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-24 4:00 ` Paul Sture @ 1998-08-25 4:00 ` Gregg E Economou 1998-08-25 4:00 ` Jordan Henderson ` (3 more replies) 0 siblings, 4 replies; 69+ messages in thread From: Gregg E Economou @ 1998-08-25 4:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1008 bytes --] thats not a feature of C. There is really only one data type in c: memory. integers, pointers, floats, etc, theyre all just memory in C. (thats the beauty of it). Now, common proctice is that when you ant to store a string-like thing, you terminate it with a null. but ther ei sno data type in C 'string' which dictates a null terminated sequence of bytes. You can do _whatever_ you want in C, which is why it is so nice, as opposed to languages where you _do_ have a 'string' type perhaps, and have to live with the accompanying rstricitons . as the famous quote goes, C provides all the power of assembly with all the flexibility of assembly *grin* happy hacking, gregg In article <35E17279.236FC9E2@ubs.com>, Paul Sture <paul.sture@ubs.com> wrote: > > >Glenn C. Everhart wrote: > >> snip > >> ... needs to acquire a notion of string size other than location of a >> null.... > >> snip > >The very first thing that put me off C!!! > >-- >Paul Sture >Z�rich > >paul dot sture at ubs dot com > > ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-25 4:00 ` Gregg E Economou @ 1998-08-25 4:00 ` Jordan Henderson 1998-08-26 4:00 ` Bob Koehler 1998-08-25 4:00 ` John Wilson ` (2 subsequent siblings) 3 siblings, 1 reply; 69+ messages in thread From: Jordan Henderson @ 1998-08-25 4:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1505 bytes --] If this is not a feature of C, then why does the ANSI C Standard Library contain so many routines that use this non-existent null-terminated string data type. Now, I agree that the C language doesn't have any support for this data type outside of it's standard library, but the standard library IS part of the language. In article <6rukse$3q0$1@usenet01.srv.cis.pitt.edu>, Gregg E Economou <geest3+@pitt.edu> wrote: >thats not a feature of C. There is really only one data type in c: >memory. integers, pointers, floats, etc, theyre all just memory in C. >(thats the beauty of it). > Now, common proctice is that when you ant to store a string-like thing, >you terminate it with a null. but ther ei sno data type in C 'string' >which dictates a null terminated sequence of bytes. You can do _whatever_ you >want in C, which is why it is so nice, as opposed to languages where you _do_ >have a 'string' type perhaps, and have to live with the accompanying rstricitons >. > >as the famous quote goes, >C provides all the power of assembly with all the flexibility of assembly >*grin* > > happy hacking, >gregg > >In article <35E17279.236FC9E2@ubs.com>, Paul Sture <paul.sture@ubs.com> wrote: >> >> >>Glenn C. Everhart wrote: >> >>> snip >> >>> ... needs to acquire a notion of string size other than location of a >>> null.... >> >>> snip >> >>The very first thing that put me off C!!! >> >>-- >>Paul Sture >>Z�rich >> >>paul dot sture at ubs dot com >> >> > > -Jordan Henderson jordan@neosoft.com ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-25 4:00 ` Jordan Henderson @ 1998-08-26 4:00 ` Bob Koehler [not found] ` <6s910k$2bo$1@Starbase.NeoSoft.COM> 0 siblings, 1 reply; 69+ messages in thread From: Bob Koehler @ 1998-08-26 4:00 UTC (permalink / raw) In article <6rv5pa$p2i$1@Starbase.NeoSoft.COM>, jordan@Starbase.NeoSoft.COM (Jordan Henderson) writes: > >Now, I agree that the C language doesn't have any support for this data >type outside of it's standard library, but the standard library IS part >of the language. > Sure it does. C provides string constants. The C expresion "Hello World" ends in a null. No string variables, no string operators, just string constants. But when one discusses C there must be some way to seperate the "language" as recognized by the compiler from the supporting functions in the library even if they are both part of the ANSI standard. Perhaps you have a better name convention? ---------------------------------------------------------------------- Bob Koehler | Computer Sciences Corporation Hubble Space Telescope Payload | Federal Sector, Civil Group Flight Software Team | please remove ".aspm" when replying ^ permalink raw reply [flat|nested] 69+ messages in thread
[parent not found: <6s910k$2bo$1@Starbase.NeoSoft.COM>]
[parent not found: <35e833be.0@news.wizvax.net>]
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * [not found] ` <35e833be.0@news.wizvax.net> @ 1998-08-29 4:00 ` Jordan Henderson 1998-08-30 4:00 ` John Wilson ` (2 more replies) 0 siblings, 3 replies; 69+ messages in thread From: Jordan Henderson @ 1998-08-29 4:00 UTC (permalink / raw) In article <35e833be.0@news.wizvax.net>, John Wilson <wilson@dbit.com> wrote: >In article <6s910k$2bo$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>I remembered that after posting that the compiler does in fact have >>support for a 'nul-terminated string' in it's string constants. There's >>another place as well, command line arguments are supported as nul-terminated >>strings. > >Nitpick: the argc/argv command line arguments *are* set up by the C >runtime library as part of the init code, so they're not part of the >core language itself. But since the C runtime init is normally linked >in without the user's permission or knowledge it *seems* like it's part >of the language. > I have to admit, I don't have the C standard at hand. However, I would be surprised if the standard >required< that command line arguments be setup by something "linked in". I believe that a conforming implementation could have the compiler writing all the code into the user's program necessary to perform this command line argument setup. I believe that a conforming implementation can write the code in-line for any Standard Library call (and optimize based on this in-lining). This seems to me to make the entire Standard Library part of the "core language". I think that, conceptually, the handling of command line arguments is part of the core language. What >is< part of the core language and what is not? And what is your justification for the separation? >John Wilson >D Bit -Jordan Henderson jordan@neosoft.com ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-29 4:00 ` Jordan Henderson @ 1998-08-30 4:00 ` John Wilson 1998-08-30 4:00 ` JF Mezei ` (2 more replies) 1998-08-30 4:00 ` Gregg E Economou 1998-09-05 4:00 ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Peter da Silva 2 siblings, 3 replies; 69+ messages in thread From: John Wilson @ 1998-08-30 4:00 UTC (permalink / raw) In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >I believe that a conforming implementation can write the code in-line >for any Standard Library call (and optimize based on this in-lining). >This seems to me to make the entire Standard Library part of the >"core language". I don't have the C Standard in hand either but it certainly seems like it would be mighty presumptuous of the compiler to inline library calls unless it first sees the right "#include <>" statements for those libraries, until that point it can't be sure that it's really a library call as opposed to some user-written function of the same name. John Wilson D Bit ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` John Wilson @ 1998-08-30 4:00 ` JF Mezei 1998-08-30 4:00 ` Chris Torek 1998-08-30 4:00 ` Lawrence Kirby 1998-09-04 4:00 ` Thor Lancelot Simon 2 siblings, 1 reply; 69+ messages in thread From: JF Mezei @ 1998-08-30 4:00 UTC (permalink / raw) John Wilson wrote: > I don't have the C Standard in hand either but it certainly seems like it > would be mighty presumptuous of the compiler to inline library calls unless > it first sees the right "#include <>" statements for those libraries, until > that point it can't be sure that it's really a library call as opposed to > some user-written function of the same name. There is no difference between a library call and a user-written function. I once worked on a project where a hacker had created his own libraries that redefined all the standard C routines (printf etc etc). The *LINKER* what what resolves the references to routines. In the old VAX-C, you had to specify the vaxcrtl.exe runtime if you want access to the "standard" C routines. #includes only serve to redefine stuff (this includes macro expansion). The K&R book is full of references to the fact that the ***C COMPILER*** generates strings that are null terminated as this is the convention for the C language. Evidently, the C library routines expect strings that abide by that convention. And as far as french fries are concerned, it is a bad example to associate them with ketchup. In canada, salt and vinagar is popular, in France, it is mayonaise. In Australia, it is tomato sauce. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` JF Mezei @ 1998-08-30 4:00 ` Chris Torek 1998-08-31 4:00 ` Gregg E Economou 0 siblings, 1 reply; 69+ messages in thread From: Chris Torek @ 1998-08-30 4:00 UTC (permalink / raw) In article <35E9DAA0.8097B24F@videotron.ca> JF Mezei <jfmezei.spamnot@videotron.ca> wrote: >There is no difference between a library call and a user-written >function. I once worked on a project where a hacker had created >his own libraries that redefined all the standard C routines ... No difference? % cat >foo.c #include <string.h> void *memory_copy(void *dst, const void *src, size_t len); void f1(int *dst, int *src) { memcpy(dst, src, sizeof *dst); } void f2(int *dst, int *src) { memory_copy(dst, src, sizeof *dst); } % cc -S -O2 foo.c -fomit-frame-pointer .file "foo.c" .version "01.01" gcc2_compiled.: .text .align 4 .globl f1 .type f1,@function f1: movl 4(%esp),%eax movl 8(%esp),%edx movl (%edx),%edx movl %edx,(%eax) ret .Lfe1: .size f1,.Lfe1-f1 .align 4 .globl f2 .type f2,@function f2: pushl $4 pushl 12(%esp) pushl 12(%esp) call memory_copy addl $12,%esp ret .Lfe2: .size f2,.Lfe2-f2 .ident "GCC: (GNU) 2.7.2.1" % If there is no difference between a call to memcpy and a call to memory_copy, why is it that f2() contains a call, but f1() does not? And if I did attempt to subvert memcpy(), when would my memcpy() get called, vs the implementation's? Does this compiler inline calls to printf() in the same way it inlines calls to memcpy()? How do you know? (*I* know, because I have to work on this compiler now and then. You could obtain the source for GCC 2.7.2.1 and read it, but how will you know what changes I may have made?) -- In-Real-Life: Chris Torek, Berkeley Software Design Inc El Cerrito, CA Domain: torek@bsdi.com +1 510 234 3167 Antispam notice: unsolicited commercial email will be handled at my consulting rate; pyramid-scheme mail will be forwarded to the FTC. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` Chris Torek @ 1998-08-31 4:00 ` Gregg E Economou 1998-08-31 4:00 ` Chris Torek 0 siblings, 1 reply; 69+ messages in thread From: Gregg E Economou @ 1998-08-31 4:00 UTC (permalink / raw) That's an optimization feature of your compiler, not a feature of the underlying language. In article <6scnqc$ilb@elf.bsdi.com>, Chris Torek <torek@elf.bsdi.com> wrote: >In article <35E9DAA0.8097B24F@videotron.ca> JF Mezei >If there is no difference between a call to memcpy and a call to >memory_copy, why is it that f2() contains a call, but f1() does >not? And if I did attempt to subvert memcpy(), when would my >memcpy() get called, vs the implementation's? > >Does this compiler inline calls to printf() in the same way it >inlines calls to memcpy()? How do you know? (*I* know, because >I have to work on this compiler now and then. You could obtain >the source for GCC 2.7.2.1 and read it, but how will you know >what changes I may have made?) happy hacking gregg ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-31 4:00 ` Gregg E Economou @ 1998-08-31 4:00 ` Chris Torek 0 siblings, 0 replies; 69+ messages in thread From: Chris Torek @ 1998-08-31 4:00 UTC (permalink / raw) In article <6scnqc$ilb@elf.bsdi.com> I noted that GCC inlines various "library" calls -- that is, things that look like ordinary function calls, in C code, turn out not to be function calls at all. In article <6sei0r$745$1@usenet01.srv.cis.pitt.edu> Gregg E Economou <geest3+@pitt.edu> writes: >That's an optimization feature of your compiler, >not a feature of the underlying language. The key question is: Is this optimization feature allowed by the language definition (ANSI X3.159 / ISO 9899)? If you say "no": Why not? If you say "yes": What does that tell us about users redefining the standard library functions themselves? For those who do not have the time to look at the standard, and are willing to believe me, the answer to the "key question" above is "yes, this optimization feature is in fact allowed by the language definition". As an implementor, I must of course supply all those functions that the compiler does not open-code in this manner. (I even have to supply the open-coded memcpy, because someone might call memcpy through a function pointer. This function need not be named "memcpy", though -- since the compiler does in fact recognize "calls" to memcpy, I might have to supply instead a function named something like "_Cruntime__stdstringf__copy_nonoverlap", or perhaps I might have to supply two routines __libc_noerrchk_memcpy and __libc_errchk_memcpy, for two different compilation environments, one of which performs runtime error-checking.) As a user of the C language, however, I should not attempt to subvert any of the implementation's functions. If I do, I may find I have tied myself to a particular set of implementations, or I might discover that I cannot use the optimization features of my compiler. None of this means you *cannot* subvert your compiler. It just means that if and when you do, you cannot generalize the result to "all C compilers". If I were to claim that supplying your own memcpy(), that consisted of a call to exit(), never made memcpy exit, you would probably wonder where I got that idea. But I can prove that at least one C program that appears to call this "exiting memcpy" does in fact continue after the call, on at least one system, in at least one mode. "It works that way on my compiler" does *not* mean "it must work that way everywhere". -- In-Real-Life: Chris Torek, Berkeley Software Design Inc El Cerrito, CA Domain: torek@bsdi.com +1 510 234 3167 Antispam notice: unsolicited commercial email will be handled at my consulting rate; pyramid-scheme mail will be forwarded to the FTC. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` John Wilson 1998-08-30 4:00 ` JF Mezei @ 1998-08-30 4:00 ` Lawrence Kirby 1998-08-30 4:00 ` JF Mezei 1998-09-04 4:00 ` Thor Lancelot Simon 2 siblings, 1 reply; 69+ messages in thread From: Lawrence Kirby @ 1998-08-30 4:00 UTC (permalink / raw) In article <35e8f9d7.0@news.wizvax.net> wilson@dbit.com "John Wilson" writes: >In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>I believe that a conforming implementation can write the code in-line >>for any Standard Library call (and optimize based on this in-lining). >>This seems to me to make the entire Standard Library part of the >>"core language". > >I don't have the C Standard in hand either but it certainly seems like it >would be mighty presumptuous of the compiler to inline library calls unless >it first sees the right "#include <>" statements for those libraries, until >that point it can't be sure that it's really a library call as opposed to >some user-written function of the same name. The names of standard library functions are reserved as identifiers with external linkage. That means that it isn't valid for a user program to provide definitions for them. Therefore a compiler is well within its rights to inline calls to functions with external linkage that have the name of a standard library function. -- ----------------------------------------- Lawrence Kirby | fred@genesis.demon.co.uk Wilts, England | 70734.126@compuserve.com ----------------------------------------- ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` Lawrence Kirby @ 1998-08-30 4:00 ` JF Mezei 1998-08-30 4:00 ` Martin Ambuhl ` (3 more replies) 0 siblings, 4 replies; 69+ messages in thread From: JF Mezei @ 1998-08-30 4:00 UTC (permalink / raw) Lawrence Kirby wrote: > The names of standard library functions are reserved as identifiers with > external linkage. That means that it isn't valid for a user program to > provide definitions for them. Therefore a compiler is well within its rights > to inline calls to functions with external linkage that have the name of > a standard library function. That is not true. 1- The list of reserved words does not include function calls. The compiler has no idea what "printf" is supposed to do. It lets the linker figure out what to do with that reference. And the parameters given to the linker define where the linker will look for these references. 2- Some compilers are used to generate code for a different target platform. For instance, the DOS "TopSpeed" C compiler is used to generate code for the PSION handheld computers. Instead of linking against the DOS libraries, it links against the PSION supplied libraries, do the reference to "printf" results in a call to a different routine which is compatible with the PSION operating system (which is not DOS). Both platforms are 80x86 based but run different operating systems. There is no way that the actual compiler on DOS would know how to translate what a "printf" might result in. 3- There are some "includes" which do define macros with the same name as a standard function call. But that is not part of the compiler itself, it is part of the "package" which includes the "includes" and the library calls that are designed to integrate with the target operating system. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` JF Mezei @ 1998-08-30 4:00 ` Martin Ambuhl [not found] ` <6scur7$qtk@bgtnsc02.wo <35EA0E22.C59E9476@videotron.ca> ` (2 subsequent siblings) 3 siblings, 0 replies; 69+ messages in thread From: Martin Ambuhl @ 1998-08-30 4:00 UTC (permalink / raw) JF Mezei wrote in message <35E9E464.AD231759@videotron.ca>... | |1- The list of reserved words does not include function calls. The compiler |has no idea | what "printf" is supposed to do. It lets the linker figure out what to do |with that | reference. And the parameters given to the linker define where the linker |will look for | these references. =========== Please reread section 7.1.3 (and 7.13) of the standard before you attempt to "correct" Lawrence Kirby ("fred"). Any time you _do_ feel that he needs correcting, think again. He is not perfect, but the odds greatly favor his being right. If you do use "printf" as an identifier, you better make damn sure 1) it does not external linkage and 2) if it has file scope (which is almost certain), stdio.h is not included ========= | |2- Some compilers are used to generate code for a different target platform. | For instance, the DOS "TopSpeed" C compiler is used to generate code for the | PSION handheld computers. Instead of linking against the DOS libraries, it | links against the PSION supplied libraries, do the reference to "printf" results | in a call to a different routine which is compatible with the PSION operating system | (which is not DOS). Both platforms are 80x86 based but run different |operating systems. | There is no way that the actual compiler on DOS would know how to translate |what a "printf" | might result in. ======= These are different implementations. If they are hosted systems, and the implementations are conforming, the standard allows only a small amount of implementation-defined behavior. After all the Scope (section 1) of the standard includes "the representation of output data produced by C programs". ======= | |3- There are some "includes" which do define macros with the same name as a |standard function | call. But that is not part of the compiler itself, it is part of the |"package" which includes | the "includes" and the library calls that are designed to integrate with |the target operating | system. ========== There is no such concept of "compiler itself" in the standard. If you want to make claims about freestanding implementations, feel free. But they will be meaningless to any general C or C++ newsgroup. A hosted implementation has very severe restrictions on your violations of the implementation's namespace. ^ permalink raw reply [flat|nested] 69+ messages in thread
[parent not found: <6scur7$qtk@bgtnsc02.wo <35EA0E22.C59E9476@videotron.ca>]
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * [not found] ` <6scur7$qtk@bgtnsc02.wo <35EA0E22.C59E9476@videotron.ca> @ 1998-08-31 4:00 ` Will Rose 0 siblings, 0 replies; 69+ messages in thread From: Will Rose @ 1998-08-31 4:00 UTC (permalink / raw) JF Mezei (jfmezei.spamnot@videotron.ca) wrote: : > >1- The list of reserved words does not include function calls. : > : > Yes it does. : I suggest you check Kernigham and Ritchie, 1978 edition. Appendix A (starts at : page 214) : Or better yet, the official list of reserved words at page 180 (again appendix A). K&R edition 1 is obsolete, and even K&R 2 isn't a definition of the language: that's an ANSI/ISO document. Get a copy of this and read it, and things will become clear to you. Will cwr@crash.cts.com ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` JF Mezei 1998-08-30 4:00 ` Martin Ambuhl [not found] ` <6scur7$qtk@bgtnsc02.wo <35EA0E22.C59E9476@videotron.ca> @ 1998-08-31 4:00 ` Michael Rubenstein 1998-08-31 4:00 ` Craig Franck 3 siblings, 0 replies; 69+ messages in thread From: Michael Rubenstein @ 1998-08-31 4:00 UTC (permalink / raw) On Sun, 30 Aug 1998 19:46:52 -0400, JF Mezei <jfmezei.spamnot@videotron.ca> wrote: >Lawrence Kirby wrote: >> The names of standard library functions are reserved as identifiers with >> external linkage. That means that it isn't valid for a user program to >> provide definitions for them. Therefore a compiler is well within its rights >> to inline calls to functions with external linkage that have the name of >> a standard library function. > >That is not true. > >1- The list of reserved words does not include function calls. The compiler >has no idea > what "printf" is supposed to do. It lets the linker figure out what to do >with that > reference. And the parameters given to the linker define where the linker >will look for > these references. This is not true. The standard function names are reserved as identifers with external linkage and, if the header declaring them is included, at file scope. From 7.1.3: - All identifiers with external linkage in any of the following subclauses [those specifying the standard library] (including the future library directions) are always reserved for use as identifiers with external linkage. - Each identifier with file scope listed in any of the following clauses (including the future library directions) is reserved for use as an identifier with file scope in the same name space if any of its associated headers is included. > >2- Some compilers are used to generate code for a different target platform. > For instance, the DOS "TopSpeed" C compiler is used to generate code for the > PSION handheld computers. Instead of linking against the DOS libraries, it > links against the PSION supplied libraries, do the reference to "printf" results > in a call to a different routine which is compatible with the PSION operating system > (which is not DOS). Both platforms are 80x86 based but run different >operating systems. > There is no way that the actual compiler on DOS would know how to translate >what a "printf" > might result in. Wyy not? It knows how to translate to the code needed to call it. Why can't it know how to translate to the code to implement it? > >3- There are some "includes" which do define macros with the same name as a >standard function > call. But that is not part of the compiler itself, it is part of the >"package" which includes > the "includes" and the library calls that are designed to integrate with >the target operating > system. An implementation MAY define macros to implement some standard functions. This is not required (there are some identifiers that are required to be macros by the standard). In any case, the functions must also be defined to allow calling them without including the header and to allow taking their address. -- Michael M Rubenstein ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` JF Mezei ` (2 preceding siblings ...) 1998-08-31 4:00 ` Michael Rubenstein @ 1998-08-31 4:00 ` Craig Franck 1998-08-30 4:00 ` JF Mezei 3 siblings, 1 reply; 69+ messages in thread From: Craig Franck @ 1998-08-31 4:00 UTC (permalink / raw) JF Mezei <jfmezei.spamnot@videotron.ca> wrote: >Lawrence Kirby wrote: >> The names of standard library functions are reserved as identifiers with >> external linkage. That means that it isn't valid for a user program to >> provide definitions for them. Therefore a compiler is well within its rights >> to inline calls to functions with external linkage that have the name of >> a standard library function. > >That is not true. Is to. >1- The list of reserved words does not include function calls. Yes it does. >The compiler has no idea what "printf" is supposed to do. A compiler is allowed to know exactly how printf is supposed to function. >It lets the linker figure out what to do with that reference. And the >parameters given to the linker define where the linker will look for >these references. One reason standard library function names are reserved with external linkage is if you define your own function with a reserved name, the linker is not going to know whether to link with your user-defined function or the standard library function. For example, having two printfs to deal with invokes undefined- behavoir. >2- Some compilers are used to generate code for a different target >platform. [...] >There is no way that the actual compiler on DOS would know how to >translate what a "printf" might result in. A compiler would probably be more limited on what it could do, but that example doesn't prove what a compiler can or can't do overall. It is still allowed to inline code and even call specially optimized versions of printf based on how it's being used. >3- There are some "includes" which do define macros with the same >name as a standard function call. But that is not part of the >compiler itself, it is part of the "package" which includes the >"includes" and the library calls that are designed to integrate >with the target operating system. I think it's generally best to think of the standard library as part of the C language itself. The fact that it may be implementated seperately really doesn't matter; whether the preprocessor is part of the compiler or a stand alone utility really doesn't matter as long as the pakage works correctly. Also, a macro may get exapanded or a function called based on how it's being used. That is part of the language. -- Craig clfranck@worldnet.att.net Manchester, NH The most savage controversies are those about matters as to which there is no good evidence either way. -- Bertrand Russell ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-31 4:00 ` Craig Franck @ 1998-08-30 4:00 ` JF Mezei 1998-08-31 4:00 ` firewind 0 siblings, 1 reply; 69+ messages in thread From: JF Mezei @ 1998-08-30 4:00 UTC (permalink / raw) > >1- The list of reserved words does not include function calls. > > Yes it does. I suggest you check Kernigham and Ritchie, 1978 edition. Appendix A (starts at page 214) Or better yet, the official list of reserved words at page 180 (again appendix A). > >The compiler has no idea what "printf" is supposed to do. > > A compiler is allowed to know exactly how printf is supposed to > function. Nop, because the compiler does not know to what library the object module will eventually be linked with. Case in point: on a VAX-VMS, you can link against the VAXCRTL or DECCRTL libraries, which, while similar, have significant differences. Obviously, if you work on a system where the linker is integrated in the compiler, there may be some optimisations that are permissible if the compiler-linker knows you will link against that supplied libraries. But that is an implementation "derivative", not part of the language. > For example, having two printfs to deal with invokes undefined- > behavoir. Some linkers allow this to happen through the use of "search order" and a switch to allow this. Furthermore, the compiler has no idea that during the link operation, instead of supplying the standard run-time as a library, you will supply a different library. Quoting from K&R, page 1: "Finally, C itself provides no input-output facilities: there are no READ or WRITE statements, and no wired-in file access methods. All these higher-level mechanisms *MUST* be provided by explicitely called functions." (emphasis on MUST is mine). By that definition alone, a compiler which assumes a certain behaviour for printf and translates it to inline code instead of a call to the printf routine in a library would not adhere to the C standards. Must be a Microsoft compiler. > Also, a macro may get exapanded or a function called based on > how it's being used. That is part of the language. Disagree. If you do not have a #include that defines the macro, the use of your "keyword" will result in a function call to be resolved by the linker. If you have a #include with a #define for your keyword, that keyword will get expanded during the pre-processor stage, prior to actual compilation. On the good old VAXC, the lack of #include <string.h> would result in references to isnum(char) being compiled as a function call. When you included string.h, isnum(char) would be expanded in macro which did the same job (but more efficiently). This varies from implementation to implementation. And it is not part of the actual C language. And you should note that it is not the compiler which generates the "inline code" but rather the pre-processor which converts a keyword into a list of C language statements which are then compiled as if you had typed them in. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` JF Mezei @ 1998-08-31 4:00 ` firewind 0 siblings, 0 replies; 69+ messages in thread From: firewind @ 1998-08-31 4:00 UTC (permalink / raw) In comp.lang.c JF Mezei <jfmezei.spamnot@videotron.ca> wrote: > I suggest you check Kernigham and Ritchie, 1978 edition. 1978 edition? How delightfully ancient! Surely you know that two standards regulating C have been passed since then, with a third on the way? K&R1 (nor K&R2) is representative of the language at this time. In fact, K&R1 -never- was representative of the state of C. > Appendix A (starts at page 214) > Or better yet, the official list of reserved words at page 180 (again > appendix A). For those of us following along in the newer edition, the list referred to can be found on page 192. The section is A2.4, Keywords, and reads as follows: The following identifiers are reserved *for use as keywords*, and may not be used otherwise: [list of 32 keywords ommitted] The emphasis in the above quote is mine, not K&R. Perhaps I have the wrong book, but I am unable to find the phrase 'reserved words' in that section. The purpose of the section is -merely- to list the 32 keywords that are -always- reserved. Other identifiers are reserved in other contexts, and the reference you provide, quoted above, does NOT refute this. > Nop, because the compiler does not know to what library the object module will > eventually be linked with. Case in point: on a VAX-VMS, you can link against > the VAXCRTL or DECCRTL libraries, which, while similar, have significanto > differences. Linkers? Libraries? What are those? Object modules? Huh? You back up your assertion that the compiler -may not- 'know' about 'printf()' by providing an example implimentation where it does not. I'm curious, have you ever read the standard? Or even glanced at it? We're not talking about what can or what does happen. We are talking about what -may- happen, and the fact is that the standard allows for an implimentation where -no- linker exists, and code for standard functions is directly inserted by the compiler. > Quoting from K&R, page 1: > "Finally, C itself provides no input-output facilities: there are no READ or > WRITE statements, and no wired-in file access methods. All these higher- > level mechanisms *MUST* be provided by explicitely called functions." > (emphasis on MUST is mine). > By that definition alone, a compiler which assumes a certain behaviour for > printf and translates it to inline code instead of a call to the printf > routine in a library would not adhere to the C standards. Must be a > Microsoft compiler. Sorry, incorrect. Besides the fact that, once again, K&R != ISO, your reading of the quoted passage is fatally flawed. It reads 'must be provided by *explicitly* called functions,' (emphasis mine) not '*external* called func- tions.' -Nowhere- does the passage you quote prohibit insertion of code by the compiler. > Disagree. If you do not have a #include that defines the macro, the use of > your "keyword" will result in a function call to be resolved by the linker. Again: what linker? -- (cfgwgid) ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-30 4:00 ` John Wilson 1998-08-30 4:00 ` JF Mezei 1998-08-30 4:00 ` Lawrence Kirby @ 1998-09-04 4:00 ` Thor Lancelot Simon 2 siblings, 0 replies; 69+ messages in thread From: Thor Lancelot Simon @ 1998-09-04 4:00 UTC (permalink / raw) In article <35e8f9d7.0@news.wizvax.net>, John Wilson <wilson@dbit.com> wrote: >In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>I believe that a conforming implementation can write the code in-line >>for any Standard Library call (and optimize based on this in-lining). >>This seems to me to make the entire Standard Library part of the >>"core language". > >I don't have the C Standard in hand either but it certainly seems like it >would be mighty presumptuous of the compiler to inline library calls unless >it first sees the right "#include <>" statements for those libraries, until >that point it can't be sure that it's really a library call as opposed to >some user-written function of the same name. Heh, heh, heh. You've just discovered the thing I hate *most* about Intel's compilers. Shame they churn out such fast code, though... they're like a drug habit, in a way. :-) -- Thor Lancelot Simon tls@rek.tjls.com "And where do all these highways go, now that we are free?" ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-29 4:00 ` Jordan Henderson 1998-08-30 4:00 ` John Wilson @ 1998-08-30 4:00 ` Gregg E Economou 1998-08-30 4:00 ` K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) Clint Comes 1998-09-05 4:00 ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Peter da Silva 2 siblings, 1 reply; 69+ messages in thread From: Gregg E Economou @ 1998-08-30 4:00 UTC (permalink / raw) Many people wouldn't think of eating fries without ketchup. However, none of those people would consider that the ketchup is a part of the fries beyond the fact that for them the fries arent consumed without the ketchup. But they can maintain the distinction in their minds. Now it is even convention to find ketchup where one finds fries- they usually even give you ketchup without asking when you buy fries. But nobody will think that fries cannot exist wihtout ketchup. In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >I have to admit, I don't have the C standard at hand. However, I would >be surprised if the standard >required< that command line arguments be setup >by something "linked in". I believe that a conforming implementation >could have the compiler writing all the code into the user's program >necessary to perform this command line argument setup. > >I believe that a conforming implementation can write the code in-line >for any Standard Library call (and optimize based on this in-lining). >This seems to me to make the entire Standard Library part of the >"core language". > >I think that, conceptually, the handling of command line arguments is >part of the core language. What >is< part of the core language and what is >not? And what is your justification for the separation? Well, command line arguments is not part of the core language in C and though in some languages they are, why should they be? What is my justification for separation? Well, something as high-level as command line arguments assumes that all programs have command line invocations. Thats a weighty assumption. You presuppose that all programs need them even if they dont have them, and thats another outlandish assumption. Things like arguments is an operating-system-specific thing. Certainly the runtime environment of the particular OS will have a convention for such things as arguments, but thats where it should be handled, not in the language! The things in the standard C library are convenience routines. To demand that they be part of the language itself places the assumption into the language that those things are things that programs cannot exist without, and show a dsitinct narrowmindedness about what programs do and a lack of creativity in implementing them. Granted, usually all you need is some simple i/o and so on, but who says that i am going to do i/o at all? By first insisting that ketchup is a part of fries and then complaining that because ketchup is part of fries your life is miserable because you cant have mayo on them, you miss the entire point of fries, ketchup, and mayo being separate entities. Now, some settings will provide you with a fries&ketchup solution that is inseperable because theyve already stuck the ketchup into the fries, and some places do likewise with mayo or vinegar. What if i just want fries? What if i like mustard on them? Those package deal places are fine for some people. Their analogy, the typed languages, provide their restricitve constructs which give high-level abstractions. C allows you the opportunity to build a high level abstraction should you wish, but also lets you choose not to, and also provides the distincitve facet of opportunity in that you can build whatever high level abstraction you like wihtout limitation. You get the fries, and can not only choose mayo or ketchup or vinegar, but can also bring your own condiment, if you wish one. ok, lets end this. happy hacking, gregg ^ permalink raw reply [flat|nested] 69+ messages in thread
* K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) 1998-08-30 4:00 ` Gregg E Economou @ 1998-08-30 4:00 ` Clint Comes 1998-08-31 4:00 ` Bob Koehler 0 siblings, 1 reply; 69+ messages in thread From: Clint Comes @ 1998-08-30 4:00 UTC (permalink / raw) First, let me state that I love ketchup, and I tend to get angry when I buy fries, and open the bag to find no ketchup. Now fries can exist without ketchup, but that begs the question "What good are fries without ketchup?" As a side note, if you want your fries with mustard, mayo, or vinegar - I'd suggest you order them that way, 'cause there's no way in hell that the guy at Wendys is going to assume you want them that way.... Now, back to my point. Is the oil/grease part of the fry? I've tried those baked potato stick thingies, but they tend to bend too much under the weight of the dern ketchup. Notice that I refer to them as "baked potato stick thingies" because they can not be fries, because fries must be *fried* to be fries. I'll assume here that in order for something to be fried, an oil or grease of some sort must be used. This would tend to make me think that grease is a required ingredient of fries. Now does this mean that oil/grease is part of the fry? I sure think so.. it's there, and it HAS to be there. Without the oil/grease what would the fry be cooked in? Water? Naw... then the'd be "poached", and there's no way that I'm going to order a large "poach" with my Quarter Pounder! What about salt? Some places (like the local McD's) have taken up the anoying habit of sometimes putting salt on the fries straight out of the fryer, while at other times they TRY to be healthy and leave the stuff off. This leaves ME in a very tough spot. If I ask for salt on my fries, then I take the chance that the window waiter will think that I mean to add salt to the fries at all cost - in other words, add salt to the already salty fries! BTW, this is very similar to the on again/off again practice of putting ketchup in the bag automatically. If I ask for it, I rick getting double the ketchup... but I'm drifting off of my point again. I also wonder about the little bag/box they put the fries into. Are they part of "fries?" The last time I took the wife out for a night on the town, we started the ball moving at "Rootys". Now I know "Rootys" is not a national burger chain, but the point I'll make with this one will be universal anyways. Back to the story - we were waiting at the table when the nice wait person brought out our meals. When asked, I directed the grilled chicken sandwich to my Love, and the 1/2 pound burger with extra fat to myself. Then something happened that now seems to be significant! She asked which one of us ordered the "atomic chilli cheese fries!" What I was handed was not a pile of potato/grease/beef/jalapeno/cheese, it was a pile of potato/grease/beef/jalapeno/cheese in a BOX!!!! Now did she mean to imply that the box was part of what was collectively called "attomic chilli cheese fries", or did she mean "atomic chilli cheese fries IN A BOX?" Either way, I felt pretty bad when we left - even worse when we got to our final destination, Putt-Putt land! God, was my wife happy to finally have an evening like that. We finally go out for one stinkin' night without us droping by the local computer store, which always leads to me bitching about the lack of Alpha compatible stuff, and the over-abudance of Mac compatible stuff.... The bottom line of all of this is this, I'm really starting to like Wendys. They ALWAYS salt their fries, ALWAYS put them in a box. Best of all, they have a big damn sign that reads "Ketchup available upon request." Just some thoughts, Clint P.S. I hope no one minds if we rename this thread.... Gregg E Economou wrote in message <6sagp1$hoi$1@usenet01.srv.cis.pitt.edu>... >Many people wouldn't think of eating fries without ketchup. However, >none of those people would consider that the ketchup is a part of the >fries beyond the fact that for them the fries arent consumed without the >ketchup. But they can maintain the distinction in their minds. >Now it is even convention to find ketchup where one finds fries- they usually >even give you ketchup without asking when you buy fries. But nobody will >think that fries cannot exist wihtout ketchup. > >In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>I have to admit, I don't have the C standard at hand. However, I would >>be surprised if the standard >required< that command line arguments be setup >>by something "linked in". I believe that a conforming implementation >>could have the compiler writing all the code into the user's program >>necessary to perform this command line argument setup. >> >>I believe that a conforming implementation can write the code in-line >>for any Standard Library call (and optimize based on this in-lining). >>This seems to me to make the entire Standard Library part of the >>"core language". >> >>I think that, conceptually, the handling of command line arguments is >>part of the core language. What >is< part of the core language and what is >>not? And what is your justification for the separation? > >Well, command line arguments is not part of the core language in C and >though in some languages they are, why should they be? > >What is my justification for separation? Well, something as high-level >as command line arguments assumes that all programs have command line >invocations. Thats a weighty assumption. You presuppose that all programs >need them even if they dont have them, and thats another outlandish >assumption. Things like arguments is an operating-system-specific thing. >Certainly the runtime environment of the particular OS will have a convention >for such things as arguments, but thats where it should be handled, not >in the language! >The things in the standard C library are convenience routines. To demand >that they be part of the language itself places the assumption into the >language that those things are things that programs cannot exist without, >and show a dsitinct narrowmindedness about what programs do and a lack of >creativity in implementing them. Granted, usually all you need is some >simple i/o and so on, but who says that i am going to do i/o at all? > >By first insisting that ketchup is a part of fries and then complaining >that because ketchup is part of fries your life is miserable because you >cant have mayo on them, you miss the entire point of fries, ketchup, and mayo >being separate entities. Now, some settings will provide you with a >fries&ketchup solution that is inseperable because theyve already stuck the >ketchup into the fries, and some places do likewise with mayo or vinegar. >What if i just want fries? What if i like mustard on them? Those package >deal places are fine for some people. Their analogy, the typed languages, >provide their restricitve constructs which give high-level abstractions. >C allows you the opportunity to build a high level abstraction should you >wish, but also lets you choose not to, and also provides the distincitve >facet of opportunity in that you can build whatever high level abstraction >you like wihtout limitation. You get the fries, and can not only choose >mayo or ketchup or vinegar, but can also bring your own condiment, if you >wish one. >ok, lets end this. > >happy hacking, >gregg > > ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) 1998-08-30 4:00 ` K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) Clint Comes @ 1998-08-31 4:00 ` Bob Koehler 1998-09-05 4:00 ` Gregg E Economou 0 siblings, 1 reply; 69+ messages in thread From: Bob Koehler @ 1998-08-31 4:00 UTC (permalink / raw) In article <6sapbh$lpv$1@supernews.com>, "Clint Comes" <ccomes@txdirect.net> writes: >As a side note, if you want your fries with mustard, mayo, or vinegar - I'd >suggest you order them that way, 'cause there's no way in hell that the guy >at Wendys is going to assume you want them that way.... Nope. Around here the thing is fries with gravy. ---------------------------------------------------------------------- Bob Koehler | Computer Sciences Corporation Hubble Space Telescope Payload | Federal Sector, Civil Group Flight Software Team | please remove ".aspm" when replying ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) 1998-08-31 4:00 ` Bob Koehler @ 1998-09-05 4:00 ` Gregg E Economou 0 siblings, 0 replies; 69+ messages in thread From: Gregg E Economou @ 1998-09-05 4:00 UTC (permalink / raw) way off topic here now, but.. :) In article <6sec6p$1n7@post.gsfc.nasa.gov>, Bob Koehler <koehler@bessta.gsfc.nasa.aspm.gov> wrote: > > >Nope. Around here the thing is fries with gravy. ditto for here (pittsburgh area).. of course here, they try to put gravy on almost everything (sandwiches, too) :) happy hacking, gregg ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-29 4:00 ` Jordan Henderson 1998-08-30 4:00 ` John Wilson 1998-08-30 4:00 ` Gregg E Economou @ 1998-09-05 4:00 ` Peter da Silva 1998-09-05 4:00 ` Jordan Henderson 2 siblings, 1 reply; 69+ messages in thread From: Peter da Silva @ 1998-09-05 4:00 UTC (permalink / raw) Hi Jordan! In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >I have to admit, I don't have the C standard at hand. However, I would >be surprised if the standard >required< that command line arguments be setup >by something "linked in". In a "hosted" implemantation that's true, but not in an "embedded" one. If you're messing around at this level you're not worried about the normal C runtime, are you? I mean, that's the point. (how else would a device driver satisfy ANSI otherwise) -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-05 4:00 ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Peter da Silva @ 1998-09-05 4:00 ` Jordan Henderson 1998-09-07 4:00 ` Peter da Silva 0 siblings, 1 reply; 69+ messages in thread From: Jordan Henderson @ 1998-09-05 4:00 UTC (permalink / raw) Hi Peter! In article <6ss8cc$qrl@web.nmti.com>, Peter da Silva <peter@baileynm.com> wrote: >Hi Jordan! > >In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>I have to admit, I don't have the C standard at hand. However, I would >>be surprised if the standard >required< that command line arguments be setup >>by something "linked in". > >In a "hosted" implemantation that's true, but not in an "embedded" one. If >you're messing around at this level you're not worried about the normal >C runtime, are you? I mean, that's the point. > I'm perplexed. What is it exactly from the above are you saying is true for a "hosted" implementation, but not in an "embedded" one? I infer you are inferring that I was saying that a C compiler had to write programs that handled command line arguments. I did not. I was only making statements about how a C implementation _may_ handle command line arguments. In an environment where command line arguments are typically not provided (device drivers, etc.) the compiler could write code into the result program that would check for the environmental restrictions at run time and provide command line arguments or not, as appropriate. Actually, it's more typical that you would have to provide special instructions to the compiler/linker/etc. when writing special device driver types of programs, but all this detail is outside of considerations of what a C compiler can and cannot do in ANSI conformant implementations. >(how else would a device driver satisfy ANSI otherwise) This is a non-sequitor. Who was claiming that a C program had to have command line argument processing to be ANSI conformant? I was claiming that if an ANSI conformant C program had command line arguments, they would all be nul-terminated strings. > >-- >In hoc signo hack, Peter da Silva <peter@baileynm.com> > `-_-' "If Microsoft don't think you need it, it's not there and there's no > 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-05 4:00 ` Jordan Henderson @ 1998-09-07 4:00 ` Peter da Silva 1998-09-07 4:00 ` Jordan Henderson 0 siblings, 1 reply; 69+ messages in thread From: Peter da Silva @ 1998-09-07 4:00 UTC (permalink / raw) In article <6ssnp9$6pv$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >In article <6ss8cc$qrl@web.nmti.com>, >Peter da Silva <peter@baileynm.com> wrote: >>In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, >>Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>>I have to admit, I don't have the C standard at hand. However, I would >>>be surprised if the standard >required< that command line arguments be setup >>>by something "linked in". >>In a "hosted" implemantation that's true, but not in an "embedded" one. If >>you're messing around at this level you're not worried about the normal >>C runtime, are you? I mean, that's the point. >I'm perplexed. What is it exactly from the above are you saying is true >for a "hosted" implementation, but not in an "embedded" one? Hmmm. I seem to have misquoted your message. The part I was responding to was this: > I think that, conceptually, the handling of command line arguments is > part of the core language. What >is< part of the core language and what is > not? And what is your justification for the separation? Basically, I think that the distinction between a hosted and embedded implementation is a good place to start. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Peter da Silva @ 1998-09-07 4:00 ` Jordan Henderson 1998-09-07 4:00 ` Peter da Silva ` (2 more replies) 0 siblings, 3 replies; 69+ messages in thread From: Jordan Henderson @ 1998-09-07 4:00 UTC (permalink / raw) Oh, well you should have said that then... In article <6svdad$ggd@web.nmti.com>, Peter da Silva <peter@baileynm.com> wrote: >In article <6ssnp9$6pv$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>In article <6ss8cc$qrl@web.nmti.com>, >>Peter da Silva <peter@baileynm.com> wrote: >>>In article <6sac4v$4ti$1@Starbase.NeoSoft.COM>, >>>Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>>>I have to admit, I don't have the C standard at hand. However, I would >>>>be surprised if the standard >required< that command line arguments be setup >>>>by something "linked in". > >>>In a "hosted" implemantation that's true, but not in an "embedded" one. If >>>you're messing around at this level you're not worried about the normal >>>C runtime, are you? I mean, that's the point. > >>I'm perplexed. What is it exactly from the above are you saying is true >>for a "hosted" implementation, but not in an "embedded" one? > >Hmmm. I seem to have misquoted your message. The part I was responding >to was this: > >> I think that, conceptually, the handling of command line arguments is >> part of the core language. What >is< part of the core language and what is >> not? And what is your justification for the separation? > >Basically, I think that the distinction between a hosted and embedded >implementation is a good place to start. > I still don't have the Standard document at hand, but does it clearly say that non-hosted systems cannot have command line arguments? I know that VRTX (and probably lots of other) real-time OS's allow you to write programs that have command lines (they implement exec(), so you have to have arguments). What exactly is the difference between hosted and non-hosted environments? Even if command line arguments are not supported in non-hosted environments, I have the string constants to fall back on for my claim that nul-terminated strings are a "feature" of the language. So, if you attempt to draw the line at hosted/non-hosted => core/extensions you still have to allow nul-terminated strings in as part of the core and not just a "convention". >-- >In hoc signo hack, Peter da Silva <peter@baileynm.com> > `-_-' "If Microsoft don't think you need it, it's not there and there's no > 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Jordan Henderson @ 1998-09-07 4:00 ` Peter da Silva 1998-09-07 4:00 ` Jordan Henderson 1998-09-08 4:00 ` Dan Pop 1998-09-07 4:00 ` Richard Stamp 1998-09-07 4:00 ` Dan Pop 2 siblings, 2 replies; 69+ messages in thread From: Peter da Silva @ 1998-09-07 4:00 UTC (permalink / raw) In article <6t18af$p83$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >I still don't have the Standard document at hand, but does it clearly >say that non-hosted systems cannot have command line arguments? No, of course not. It says that hosted systems *do*. For embedded systems it's undefined behaviour, and you're allowed to initiate posterior expulsion of avian primates[1] if you see main(int ac, char **av). >Even if command line arguments are not supported in non-hosted environments, >I have the string constants to fall back on for my claim that nul-terminated >strings are a "feature" of the language. No, nul-terminated string *constants* are. What you do with them after that is outside the language definition, and since sizeof("...") does the right thing you can have any character, including a nul, in one. (in fact I recall writing code that involve doubly-nul-terminated string constants[2], and in embedded environments I've had occasion to use $ as the terminator[3]) [1] STR [2] while(*(p+=strlen(p)+1) != '\0') ... [3] mercifully I've forgotten the RTOS that chose a printing character, but not the subtle bugs generated by passing financial info to their runtime. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Peter da Silva @ 1998-09-07 4:00 ` Jordan Henderson 1998-09-08 4:00 ` Tim Shoppa ` (2 more replies) 1998-09-08 4:00 ` Dan Pop 1 sibling, 3 replies; 69+ messages in thread From: Jordan Henderson @ 1998-09-07 4:00 UTC (permalink / raw) In article <6t1i0l$241@web.nmti.com>, Peter da Silva <peter@baileynm.com> wrote: >In article <6t18af$p83$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>I still don't have the Standard document at hand, but does it clearly >>say that non-hosted systems cannot have command line arguments? > >No, of course not. It says that hosted systems *do*. For embedded >systems it's undefined behaviour, and you're allowed to initiate >posterior expulsion of avian primates[1] if you see main(int ac, char >**av). > >>Even if command line arguments are not supported in non-hosted environments, >>I have the string constants to fall back on for my claim that nul-terminated >>strings are a "feature" of the language. > >No, nul-terminated string *constants* are. What you do with them after that >is outside the language definition, and since sizeof("...") does the right >thing you can have any character, including a nul, in one. > This is getting absurd. If nul-terminated string *constants* are a "feature" of the language, then so are nul-terminated strings. Denying this is like saying that ints aren't a part of the language, just int constants. After all, what you _do_ with an int variable is outside of the definition of the language. I know, there's a subtle difference. int is a data type, but the nul-terminated string is not. I would claim that the reason there is no nul-terminated string data type in the language is one of economy. char * works so well and is so flexible that you don't need a data type. The nul-terminated string may not enjoy the status of "data type" in C, but I still claim that it is a "feature" of the language. The nul-terminated string is intimately linked to the logical expression semantics (you can do things like "while (*s++) {"). It was thought to be so integral that the string constant used it. Also, the entire Standard Library makes heavy use of it. I still claim that it's a feature of the language. You can demonstrate programs that use other character handling techniques, just like one could demonstrate alternate integer numeric representations in legal C language programs without using integral types. As I said, this is getting absurd. It's just a semantic question without an authority to decide it. I would expect that the Standard is silent on what constitutes a "feature". I still think arguing that the nul-terminated string is not a "feature", for any reasonable definition of "feature" is just pointless contentiousness. >(in fact I recall writing code that involve doubly-nul-terminated string >constants[2], and in embedded environments I've had occasion to use $ as the >terminator[3]) > >[1] STR >[2] while(*(p+=strlen(p)+1) != '\0') ... >[3] mercifully I've forgotten the RTOS that chose a printing character, but > not the subtle bugs generated by passing financial info to their runtime. > >-- >In hoc signo hack, Peter da Silva <peter@baileynm.com> > `-_-' "If Microsoft don't think you need it, it's not there and there's no > 'U` way to include it yourself." -- Geoff Lane, a.s.r. -Jordan Henderson jordan@neosoft.com ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Jordan Henderson @ 1998-09-08 4:00 ` Tim Shoppa [not found] ` <6t4cui$hfu@espresso.cafe.net> 1998-09-08 4:00 ` Peter da Silva 1998-09-08 4:00 ` JF Mezei 2 siblings, 1 reply; 69+ messages in thread From: Tim Shoppa @ 1998-09-08 4:00 UTC (permalink / raw) In article <6t24vj$kep$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >If nul-terminated string *constants* are a "feature" of the language, then >so are nul-terminated strings. It's been a while since you programmed in MACRO-11 or -32, isn't it? :-) Remember .ASCIZ ? MACRO VAX_MACRO_Assembler Directives .ASCIx .ASCIZ Performs the same function as .ASCII, except that .ASCIZ appends a null byte as the final character of the string. When a list or text string is created with an .ASCIZ directive, you need only perform a search for the null character in the last byte to determine the end of the string. Are you going to tell me that null-terminated strings are a "feature" of the PDP-11 instruction set because there's a MACRO-11 directive that creates them? (And, yes, the PDP-11 example is relevant here because that was the architecture that C was developed for.) Tim. (shoppa@triumf.ca) ^ permalink raw reply [flat|nested] 69+ messages in thread
[parent not found: <6t4cui$hfu@espresso.cafe.net>]
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * [not found] ` <6t4cui$hfu@espresso.cafe.net> @ 1998-09-09 4:00 ` Tim Shoppa 1998-09-08 4:00 ` JF Mezei 1998-09-09 4:00 ` Dan Pop 0 siblings, 2 replies; 69+ messages in thread From: Tim Shoppa @ 1998-09-09 4:00 UTC (permalink / raw) In article <6t4cui$hfu@espresso.cafe.net>, Kaz Kylheku <kaz@cafe.net> wrote: >In article <6t4dca$k0h$1@nntp.ucs.ubc.ca>, >Tim Shoppa <shoppa@alph02.triumf.ca> wrote: >>Are you going to tell me that null-terminated strings are a "feature" >>of the PDP-11 instruction set because there's a MACRO-11 directive >>that creates them? > >No; what I would say that null terminated strings are a feature of your >MACRO-11 assembly language. Are you sure you want to say that? I'd call them a feature of the PDP-11 instruction set before I called them a feature of MACRO-11, but as Jordan points out we haven't yet defined "feature". Personally, I'd say that a "feature" is something that is consciously designed in at a given level; if higher-level tools take advantage of that lower-level feature, I'd call it a "commonly used shortcut". For example, if in PDP-11 assembler I want to move a string pointed to by R2 to an area pointed to by R3, I just say: LOOP: MOVB (R2)+,(R3)+ BNE LOOP If I tried to do this any other way - say by prepending the string length, or by appending a FF or a '$' - the code gets longer (though not necessarily slower...) Not surprisingly, the C code gets longer if you use a different terminator, too :-) C's notation *and* commonly used shortcuts are incredibly strongly tied to the PDP-11 instruction set, addressing modes, and branch conditions. And these are incredibly strongly tied to minicomputer technology in the late 60's/early 70's, which is strongly tied to TI's 7400 series logic. How far back does the "feature" stop and the "commonly used shortcut" begin? Tim. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-09 4:00 ` Tim Shoppa @ 1998-09-08 4:00 ` JF Mezei 1998-09-09 4:00 ` Dan Pop 1 sibling, 0 replies; 69+ messages in thread From: JF Mezei @ 1998-09-08 4:00 UTC (permalink / raw) re: .ASCIZ macro directive in PDP11 Tim Shoppa wrote: > Are you sure you want to say that? I'd call them a feature of the > PDP-11 instruction set before I called them a feature of MACRO-11, but > as Jordan points out we haven't yet defined "feature". ASCIZ is not an instruction. It is a fair bet that it does not generate any opcodes per say but rather just allocates storage whose contents happen to be a null terminated string. It is a directive which is executed upon by the MACRO-11 "compiler", instead of executed at run-time. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-09 4:00 ` Tim Shoppa 1998-09-08 4:00 ` JF Mezei @ 1998-09-09 4:00 ` Dan Pop 1998-09-09 4:00 ` Peter da Silva 1 sibling, 1 reply; 69+ messages in thread From: Dan Pop @ 1998-09-09 4:00 UTC (permalink / raw) In <6t4h4d$mo4$1@nntp.ucs.ubc.ca> shoppa@alph02.triumf.ca (Tim Shoppa) writes: >Are you sure you want to say that? I'd call them a feature of the >PDP-11 instruction set before I called them a feature of MACRO-11, but ... >For example, if in PDP-11 assembler I want to move a string >pointed to by R2 to an area pointed to by R3, I just say: > >LOOP: MOVB (R2)+,(R3)+ > BNE LOOP In other words, the PDP-11 instruction set does NOT contain *any* instruction for C string manipulation, you have to do that with programmed loops, just as you'd do it on any other processor. Using your logic, this is a feature of any processor's instruction set. >If I tried to do this any other way - say by prepending the string length, >or by appending a FF or a '$' - the code gets longer Again, testing against zero takes fewer bytes on many instruction sets. >(though not necessarily slower...) If the operation is not copying the string but something needing the length of the string (e.g. strlen() or strcat()), prepending the string length is provably faster. Try to implement strlen() for Pascal-style strings in PDP-11 assembler and you'll discover that Pascal-style strings are a feature of the PDP-11 instruction set :-) It takes exactly one instruction, besides the RET (RTS R6). The same thing for C strings (optimized for instruction count) would be something like: MOV -1,R0 LOOP: INC R0 TSTB (R2)+ BNE LOOP Dan -- Dan Pop CERN, IT Division Email: Dan.Pop@cern.ch Mail: CERN - EP, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-09 4:00 ` Dan Pop @ 1998-09-09 4:00 ` Peter da Silva 0 siblings, 0 replies; 69+ messages in thread From: Peter da Silva @ 1998-09-09 4:00 UTC (permalink / raw) Forth symbol strings are a feature of the PDP-11 instruction set, too: LOOP: MOVB (R1)+,(R2)+ BLE LOOP ;may be terminated by high bit set or nul Forth counted strings are a feature of C: type("string", sizeof "string"-1); And the PDP-11: BNE R3,END LOOP: MOVB (R1)+,(R2)+ DSZ R3, LOOP OK, like, C string constants bias it slightly towards nul-terminated strings, but not anything like the way strings in higher level languages do. And having two indications available for the string length (the result of sizeof and the terminator) means you can go either way easily. From experience in other languages that have NO alternative to a standard string format, or which don't give you ANY clues as to the length of a string if you don't provide your own terminator (can you say PL/M?), this teeny bias is like nothing. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Jordan Henderson 1998-09-08 4:00 ` Tim Shoppa @ 1998-09-08 4:00 ` Peter da Silva [not found] ` <6t2im5$mke@espresso.cafe.net> 1998-09-08 4:00 ` Peter da Silva 1998-09-08 4:00 ` JF Mezei 2 siblings, 2 replies; 69+ messages in thread From: Peter da Silva @ 1998-09-08 4:00 UTC (permalink / raw) In article <6t24vj$kep$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >If nul-terminated string *constants* are a "feature" of the language, then >so are nul-terminated strings. Denying this is like saying that >ints aren't a part of the language, just int constants. After all, what >you _do_ with an int variable is outside of the definition of the language. The language defines operations on ints. It defines operations on pointers to characters. It doesn't define any operations on strings. This isn't nit-picking[1]. You can define an environment where all string operations are performed on opaque objects, and string constants are only used to initialize them by calling a macro "string(foo)", and the compiler is allowed to optimise "string(foo)" at compile time to a reference to that opaque object, with no run-time overhead at all. If there were built-in operations on strings that no longer worked on this opaque object then that wouldn't be the case. [1] Well, not entirely. Like, you couldn't redefine strings like this in Pascal or Fortran or Modula. In any case I've obviously let my c-language-pedant skills get rusty... I messed up on exactly when the winged monkeys are invoked, so I best go meditate on The Standard again. Reading the Version 6 source code really messes you up, you know. There's some heavily abusive code in there. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
[parent not found: <6t2im5$mke@espresso.cafe.net>]
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * [not found] ` <6t2im5$mke@espresso.cafe.net> @ 1998-09-08 4:00 ` Peter da Silva 0 siblings, 0 replies; 69+ messages in thread From: Peter da Silva @ 1998-09-08 4:00 UTC (permalink / raw) In article <6t2im5$mke@espresso.cafe.net>, Kaz Kylheku <kaz@cafe.net> wrote: >In article <6t2c1i$7on@web.nmti.com>, >Peter da Silva <peter@baileynm.com> wrote: >>In article <6t24vj$kep$1@Starbase.NeoSoft.COM>, >>Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>>If nul-terminated string *constants* are a "feature" of the language, then >>>so are nul-terminated strings. Denying this is like saying that >>>ints aren't a part of the language, just int constants. After all, what >>>you _do_ with an int variable is outside of the definition of the language. >>The language defines operations on ints. It defines operations on pointers >>to characters. It doesn't define any operations on strings. >It does: <string.h>. This library defines operations on string objects, which >are represented by a pointer to their first character. That is not the same >thing as defining operations on pointers to char. That's part of the library. A non-hosted implementation doesn't have to provide it, and in fact can have a completely different file called "string.h" and have completely different semantics for anything defined therein. >Would you also claim that C has no operations on streams, merely operations on >FILE * pointers? No, I'd claim it has neither. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-08 4:00 ` Peter da Silva [not found] ` <6t2im5$mke@espresso.cafe.net> @ 1998-09-08 4:00 ` Peter da Silva 1 sibling, 0 replies; 69+ messages in thread From: Peter da Silva @ 1998-09-08 4:00 UTC (permalink / raw) In article <6t2c1i$7on@web.nmti.com>, Peter da Silva <peter@baileynm.com> wrote: >In article <6t24vj$kep$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>If nul-terminated string *constants* are a "feature" of the language, then >>so are nul-terminated strings. Denying this is like saying that >>ints aren't a part of the language, just int constants. After all, what >>you _do_ with an int variable is outside of the definition of the language. >The language defines operations on ints. It defines operations on pointers >to characters. It doesn't define any operations on strings. I have to apologise, this is exactly equivalent to what Jordan was saying when he said: > I know, there's a subtle difference. int is a data type, but the > nul-terminated string is not. I missed that, and have been justly reprimanded for missing that, and I'll slow down now and try and see if I can't express myself better. In another message. When I've had more time to think about exactly what the point is. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Jordan Henderson 1998-09-08 4:00 ` Tim Shoppa 1998-09-08 4:00 ` Peter da Silva @ 1998-09-08 4:00 ` JF Mezei 2 siblings, 0 replies; 69+ messages in thread From: JF Mezei @ 1998-09-08 4:00 UTC (permalink / raw) Jordan Henderson wrote: > If nul-terminated string *constants* are a "feature" of the language, then > so are nul-terminated strings. Denying this is like saying that > ints aren't a part of the language, just int constants. After all, what > you _do_ with an int variable is outside of the definition of the language. I do not know what the current C standard calls a "string", but in the older version of C, "strings" were arrays of single characters. Character constants are not really an array of characters but rather a pointer to a null terminated string stored somwehere in the galaxy. The "sizeof" on a character array yields allocated space, not the string's length. char is a data type. string isn't. You can't redefine the way the C compiler generates string constants, but what you do with a string array is up to you. The big question is whether you compiler's implementation allows you to redefine string handling functions and use your own. If so, then you can redefine the way a string is stored, and write your own string functions/macros (such as strlen) that act on your own way of storing strings. (As long as you don't use constants). But should ask: why not name your own copy of sting functions differently instead of working against the C supplied routines ? ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Peter da Silva 1998-09-07 4:00 ` Jordan Henderson @ 1998-09-08 4:00 ` Dan Pop 1998-09-08 4:00 ` Peter da Silva 1 sibling, 1 reply; 69+ messages in thread From: Dan Pop @ 1998-09-08 4:00 UTC (permalink / raw) In <6t1i0l$241@web.nmti.com> peter@baileynm.com (Peter da Silva) writes: >In article <6t18af$p83$1@Starbase.NeoSoft.COM>, >Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >>I still don't have the Standard document at hand, but does it clearly >>say that non-hosted systems cannot have command line arguments? > >No, of course not. It says that hosted systems *do*. For embedded >systems it's undefined behaviour, There is no way it can be undefined behaviour. If main() does anything special on a certain freestanding environment, the accompanying documentation MUST say so. >and you're allowed to initiate >posterior expulsion of avian primates[1] if you see main(int ac, char >**av). Nonsense. You can safely define a function main(int foo, char **bar) in a freestanding environment, it's just that it won't do anything special, unless the documentation of the compiler says otherwise. >>Even if command line arguments are not supported in non-hosted environments, >>I have the string constants to fall back on for my claim that nul-terminated >>strings are a "feature" of the language. > >No, nul-terminated string *constants* are. What you do with them after that >is outside the language definition, Not quite. Quoting from the language definition (the original ANSI version): 4.1.1 Definitions of terms A string is a contiguous sequence of characters terminated by and including the first null character. It is represented by a pointer to its initial (lowest addressed) character and its length is the number of characters preceding the null character. >and since sizeof("...") does the right >thing you can have any character, including a nul, in one. In a string literal, yes. In a string, by definition, you can't have embedded null characters. >(in fact I recall writing code that involve doubly-nul-terminated string >constants[2], and in embedded environments I've had occasion to use $ as the >terminator[3]) CP/M-80 and, later, MS-DOS, used the $ as the string terminator for some OS system calls. Dan -- Dan Pop CERN, IT Division Email: Dan.Pop@cern.ch Mail: CERN - EP, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-08 4:00 ` Dan Pop @ 1998-09-08 4:00 ` Peter da Silva 1998-09-08 4:00 ` Dan Pop 0 siblings, 1 reply; 69+ messages in thread From: Peter da Silva @ 1998-09-08 4:00 UTC (permalink / raw) In article <danpop.905217598@news.cern.ch>, Dan Pop <Dan.Pop@cern.ch> wrote: >>and you're allowed to initiate >>posterior expulsion of avian primates[1] if you see main(int ac, char >>**av). >Nonsense. You can safely define a function main(int foo, char **bar) in >a freestanding environment, it's just that it won't do anything special, >unless the documentation of the compiler says otherwise. Fair enough. If the documentation says that this initiates posterior expulsion of avian primates then that's what happens. The C standard doesn't, in any case, specify it. > 4.1.1 Definitions of terms > A string is a contiguous sequence of characters terminated by and > including the first null character. It is represented by a pointer to > its initial (lowest addressed) character and its length is the number > of characters preceding the null character. Other than string literals, though, is there anything in a non-hosted environment that deals with strings? -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-08 4:00 ` Peter da Silva @ 1998-09-08 4:00 ` Dan Pop 0 siblings, 0 replies; 69+ messages in thread From: Dan Pop @ 1998-09-08 4:00 UTC (permalink / raw) In <6t2b74$7j4@web.nmti.com> peter@baileynm.com (Peter da Silva) writes: >In article <danpop.905217598@news.cern.ch>, Dan Pop <Dan.Pop@cern.ch> wrote: >>>and you're allowed to initiate >>>posterior expulsion of avian primates[1] if you see main(int ac, char >>>**av). > >>Nonsense. You can safely define a function main(int foo, char **bar) in >>a freestanding environment, it's just that it won't do anything special, >>unless the documentation of the compiler says otherwise. > >Fair enough. If the documentation says that this initiates posterior >expulsion of avian primates then that's what happens. The C standard doesn't, >in any case, specify it. The C standard does not approve such a behaviour. Defining main(int ac, char **av) could "initiate posterior expulsion of avian primates" *only* as a result of undefined behaviour. But such a definition does NOT invoke undefined behaviour, so whatever happens has to be compatible with the definition of the language. >Other than string literals, though, is there anything in a non-hosted >environment that deals with strings? That's up to the implementor. A non-hosted environment is not required to implement the whole language specification. Dan -- Dan Pop CERN, IT Division Email: Dan.Pop@cern.ch Mail: CERN - EP, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Jordan Henderson 1998-09-07 4:00 ` Peter da Silva @ 1998-09-07 4:00 ` Richard Stamp 1998-09-07 4:00 ` Dan Pop 2 siblings, 0 replies; 69+ messages in thread From: Richard Stamp @ 1998-09-07 4:00 UTC (permalink / raw) Jordan Henderson wrote in message <6t18af$p83$1@Starbase.NeoSoft.COM>... >I still don't have the Standard document at hand, but does it clearly >say that non-hosted systems cannot have command line arguments? The opposite of "hosted" is "freestanding". It doesn't say "a freestanding implementation shall not provide a method to obtain command-line arguments", if that's what you mean, but equally it doesn't say that such a method _must_ be provided. A freestanding implementation doesn't even have to start the program by calling main(). >What exactly is the difference between hosted and non-hosted environments? A freestanding implementation, as mentioned above, calls an implementation defined funtion (not necessarily main) to start the program. If the program terminates, the effect is implementation-defined (in embedded systems it may not be expected that the program ever terminate, of course). Most significantly, freestanding implementations don't need to have the standard library -- "any library facilities available to a freestanding program are implementation-defined". Similarly, they only have to provide the headers float.h, limits.h, stdarg.h and stddef.h. >Even if command line arguments are not supported in non-hosted >environments, I have the string constants to fall back on for my claim >that nul-terminated strings are a "feature" of the language. Right, but of course all the string-handling functions (strlen etc.) are off-limits. >So, if you >attempt to draw the line at hosted/non-hosted => core/extensions you still >have to allow nul-terminated strings in as part of the core and not just a >"convention". This is getting alarmingly close to the notorious "is the library a part of the language" bust-up we had in comp.lang.c a while ago -- around last Christmas, IIRC. It's extremely hard to draw a line which will satisfy most people, or indeed anyone other than yourself (and believe me, some of us tried). The only line which seems to have widespread acceptance is "standard or non-standard" and that's only because we have a 200-odd page document to define it. Cheers, Richard -- Richard Stamp, Bournemouth, UK ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-07 4:00 ` Jordan Henderson 1998-09-07 4:00 ` Peter da Silva 1998-09-07 4:00 ` Richard Stamp @ 1998-09-07 4:00 ` Dan Pop 2 siblings, 0 replies; 69+ messages in thread From: Dan Pop @ 1998-09-07 4:00 UTC (permalink / raw) In <6t18af$p83$1@Starbase.NeoSoft.COM> jordan@Starbase.NeoSoft.COM (Jordan Henderson) writes: >In article <6svdad$ggd@web.nmti.com>, >Peter da Silva <peter@baileynm.com> wrote: >>In article <6ssnp9$6pv$1@Starbase.NeoSoft.COM>, >>Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: >> >>> I think that, conceptually, the handling of command line arguments is >>> part of the core language. What >is< part of the core language and what is >>> not? And what is your justification for the separation? >> >>Basically, I think that the distinction between a hosted and embedded >>implementation is a good place to start. >> > >I still don't have the Standard document at hand, but does it clearly >say that non-hosted systems cannot have command line arguments? It just doesn't say anything about this issue WRT freestanding (non-hosted) environments. There is nothing in the standard preventing freestanding environments from providing access to command line arguments, if the very concept of "command line argument" has any meaning for that particular freestanding environment. But the mechanism used to pass them is not necessarily the same as in the case of a hosted environment (the arguments of main()). >I know that VRTX (and probably lots of other) real-time OS's allow you >to write programs that have command lines (they implement exec(), so >you have to have arguments). > >What exactly is the difference between hosted and non-hosted environments? I'll append the exact text from the standard. In a nutshell, a hosted environment benefits from the existence of an operating system, while a freestanding one doesn't. Think of a workstation versus a toaster. BTW, the operating system *itself* is running in a freestanding environment. To some operating systems you can pass command line arguments (e.g. this is how you boot most Unices in single user mode), to others you can't (e.g. CP/M, MS-DOS, Windows 95). >Even if command line arguments are not supported in non-hosted environments, >I have the string constants to fall back on for my claim that nul-terminated >strings are a "feature" of the language. Indeed, they are a feature of the language. Dan 2.1.2.1 Freestanding environment In a freestanding environment (in which C program execution may take place without any benefit of an operating system), the name and type of the function called at program startup are implementation-defined. There are otherwise no reserved external identifiers. Any library facilities available to a freestanding program are implementation-defined. The effect of program termination in a freestanding environment is implementation-defined. 2.1.2.2 Hosted environment A hosted environment need not be provided, but shall conform to the following specifications if present. "Program startup" The function called at program startup is named main . The implementation declares no prototype for this function. It can be defined with no parameters: int main(void) { /*...*/ } or with two parameters (referred to here as argc and argv , though any names may be used, as they are local to the function in which they are declared): int main(int argc, char *argv[]) { /*...*/ } If they are defined, the parameters to the main function shall obey the following constraints: * The value of argc shall be nonnegative. * argv[argc] shall be a null pointer. * If the value of argc is greater than zero, the array members argv[0] through argv[argc-1] inclusive shall contain pointers to strings, which are given implementation-defined values by the host environment prior to program startup. The intent is to supply to the program information determined prior to program startup from elsewhere in the hosted environment. If the host environment is not capable of supplying strings with letters in both upper-case and lower-case, the implementation shall ensure that the strings are received in lower-case. * If the value of argc is greater than zero, the string pointed to by argv[0] represents the program name ;argv[0][0] shall be the null character if the program name is not available from the host environment. If the value of argc is greater than one, the strings pointed to by argv[1] through argv[argc-1] represent the program parameters . * The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program, and retain their last-stored values between program startup and program termination. "Program execution" In a hosted environment, a program may use all the functions, macros, type definitions, and objects described in the library section ($4). "Program termination" A return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument. If the main function executes a return that specifies no value, the termination status returned to the host environment is undefined. -- Dan Pop CERN, IT Division Email: Dan.Pop@cern.ch Mail: CERN - EP, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * [not found] ` <6s910k$2bo$1@Starbase.NeoSoft.COM> [not found] ` <35e833be.0@news.wizvax.net> @ 1998-08-29 4:00 ` Gregg E Economou 1998-08-30 4:00 ` Jay Maynard 1 sibling, 1 reply; 69+ messages in thread From: Gregg E Economou @ 1998-08-29 4:00 UTC (permalink / raw) why must people consistently fault the tool for what really ought to be blamed (if they think it is so terrible) on those _using_ the tool. First of all, you might see less of these poor unrobust programs from other languages not because it is more difficult to write bad programs in other languages, but perhaps because other languages arent useful enough to do what they needed to do. perhaps? maybe? think about it. No i do not want to start a language war. Next issue: for the last and final time, neither the standard library, nor the run-time init/exit routines, nor command arguments, nor strings, are part of C. They have been bundled with it (implemented for one's respective operating envionrment) in _most_ instances of a C compiler, for a long time now, and as a matter of convention and according to ANSI are part of a C development environment. however they are NOT part of the actual language! how hard is it for people to understand this? Because of the existing convention that the commonly encountered need for some text to be handled primarily for purposes of i/o, that the location and size of this text be identified as beginning at some known location and ending at the next instance of a null, current and future support for this method of handling a 'string' will exist. Humans are creatures of habit. But there is no such thing as a string in C. There is no such thing as a command line argument in C, or a command line. All those things are conventions dictated by the design of various operating systems which poeple commonly deal with, and with what facilities the designers of various hardware environments chose to provide the user with, and the authors of C comilers subsequently designed their product around. Libraries, including the 'standard' library, are merely archives of precompiled object code. Their headers are merely declarations so that the linker can handle them and that the compiler can allocate necessary accomodations for them. The librariesin C are written in C, they are not part of C. end of story! i cant believe i am still explaining this to people! Other languages which do enforce strict type checking, bounds checking, control of this and that and the other thing, and have all kinds of anal hierarchies, have their advantages of 'safety' and 'integrity' but like all such 'safetey' nets, they do so by restricting, hindering, or outright prohibiting the user from certain sets of operations which on the underlying machine are perfectly legal. This in my humble opinion constitutes a reduction in the utility of the system by reducing the size of the set of things i have at my disposal as services of the hardware to perform the work i want done, and forces me to use a smaller set of rigidly defined services that someone else thought were a nice thing to have. My requirements and goals are not one and the same wiht whoever else came along, and consequently i will be forced, if i wish to use a rigid and strongly typed language, to beat my problem into the right shape for the mold instead of beat the machine into the shape for my problem. That in a nutshell is why C has its advantages. Certainly for people who are afraid of making a mistake they can go use some other language and i hope they enjoy it- but dont start accusing C of things that have little or nothign to do with C!! In article <6s910k$2bo$1@Starbase.NeoSoft.COM>, Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote: > >I remembered that after posting that the compiler does in fact have >support for a 'nul-terminated string' in it's string constants. There's >another place as well, command line arguments are supported as nul-terminated >strings. neither of those are such because of any underlying requirement in C. Read the source code to your compiler. You will see that the support for 'null terminated strings' was an arbitrary decision and could just as easily been done in some other fashion had people wished it. in fact, there are on some systems libraries with routines already made for convenience of handling counted strings. > >I won't argue the fine semantic point of C not having a nul-terminated >string 'data type', it's pointless. I will argue that nul-terminated >strings are a 'feature' of the language, which is what the original >poster was saying (that they weren't). um, no, the original poster flamed C out for having this dependence on null-terminated strings. Then myself and several other gentlemen countered with the information that that was an arbitrary convention among programmers and had nothing to do with C itself. Then this whole thing started :) > >In some languages, it might be useful to separate the "language" from the >standard library. Not in C. For example, any of the standard library >functions can be implemented >by the compiler< as in-line calls. The implemented by the compiler? um, do you know what youre talking about? the libraries are just a bunch of somebody else's code that has been written for you, for your convenience, which you glue into your program through essentially concatenation of object code and linking of jump addresses. >compiler can know about the standard library in very intimate ways. um, no, not really necessary. Yeah, some implementationsof the standard library have been optimized through extensive inlining, but hell most compilers will udnerstand some macro or preprocessor directive to pass inline code to the assembler as well so you can do that yourself should you so wish. this does not change the fact that the library is not part of the language. > >If you want to try and separate the standard library from the language, >you could still point to the fact that the string constant and command >line arguments are nul-terminated, ON ALL CONFORMING IMPLEMENTATIONS. conforming to what? implementations of what? of the library? if you just separated the library form the language (ignoring for a moment the fact that they arend bound to begin with), then you musnt mean that. what else is there? run-time init code and exit/return code? thats specific to the operating system. but it isnt part of or specific to C. >This is not just a 'convention'. Without jumping through absurd >contortions, every C programmer will have to deal with nul-terminated >strings at one time or another. Noone, except PERHAPS in some odd >embedded application that has no command line args and avoids string >constants for some ROM initialiization reason, who programs in C can >avoid them. so really you are complaining that many operating systems deal with null-terminated strings by convention and you're forced to handle this too. Well, here is some news: if you were to write a fortran or pascal program under such an environment, all those command line and environment items would if they were to appear as some more structured 'string' types, been converted by some code that ran as part of the runtime init that was generated by the linker on your OS. your orgram, though you yourself might not see it, would still be dealing with them :) > >Without getting mired in pointless debate about what constitutes a 'data type' >and where do we draw the line between standard library and 'language' and >what do we call them, I'd like to say that I think that nul-terminated >strings most certainly are a feature of C, and always have been. um, no. weve been trying to explain that its not, and show why it has been so commonly misconstrued as such as a result of common practice. > >The original discussion was about how this feature of C leads to >dangerous programming practices. Since, as I believe, you can't >avoid nul-terminated strings in the real world, I would then go >on to claim that C forces upon you practices that are can lead to >non-robust programs, more so than other languages. I recognize youre really on thin ice here. If is so choose i can just as easily write crap in any language I choose, be it C, pascal, ada, cobol, or english. The language does not force you to write crap. If you have personal difficulty in handling null-terminated strings and thus wish to fault the language, which is innocent of the whoel matter, thats your (misguided) perrogative, we're all free people here. >the trade-offs, the convenience that you get with C. It's still >the only language that's in wide use that will allow you to write >SO much of an OS kernel in it. It may be a good way to avoid >assembly language. > >I think the relative unreliability of applications written in C What are you talking about? unless you have a flaky compiler, your programs will not be unreliable merely because theyre written in C! they will be unreliable if you have not thought your algorithm through and have therefore written an incorrect program. Then you have only yourself to fault, and blaming the language is simply immature and ridiculous. >has SOMETHING to do with 'features' of the system. Sure, you >could write C without command line arguments, without string >constants and without using the standard library, but you speak for yourself. When fancy takes me to, or my requirements dictate that i do, i do :) >wouldn't. Same for pointer arithmetic, a useful feature, but >too easily abused and leading to unrobust programs. thats only if you as the programmer are incapable of properly using the tool. Is a screwdriver to be faulted if a mechanic puts a door on backwards? happy hacking, gregg ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-29 4:00 ` Gregg E Economou @ 1998-08-30 4:00 ` Jay Maynard 0 siblings, 0 replies; 69+ messages in thread From: Jay Maynard @ 1998-08-30 4:00 UTC (permalink / raw) I use C. I like C. I program almost exclusively in C. However: On 29 Aug 1998 19:49:37 GMT, Gregg E Economou <geest3+@pitt.edu> wrote: >Next issue: for the last and final time, neither the standard library, >nor the run-time init/exit routines, nor command arguments, nor strings, >are part of C. They have been bundled with it (implemented for one's >respective operating envionrment) in _most_ instances of a C compiler, >for a long time now, and as a matter of convention and according to ANSI >are part of a C development environment. however they are NOT part of the >actual language! how hard is it for people to understand this? A difference that makes no difference is no difference. Very few programmers use just a C compiler. (Folks writing embedded systems, and that's about it.) To the rest of the programming world, the language includes the runtime startup, and the standard library, and string constants, and everything else. It really doesn't matter where a particular feature is implemented; it only matters that it is. Here's an exercise for you, Gregg: Implement a C environment that uses Pascal-style counted strings instead of null-terminated ones. Try to get it ANSI-certified. Try to sell it as C. If you are caught, the Secretary will disavow any knowledge of your actions. Good luck, Mr. Economou. Now, can we PLEASE quit picking this particular nit? ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-25 4:00 ` Gregg E Economou 1998-08-25 4:00 ` Jordan Henderson @ 1998-08-25 4:00 ` John Wilson 1998-08-26 4:00 ` Gregg E Economou 1998-08-26 4:00 ` Bob Koehler 1998-08-26 4:00 ` Paul Sture 3 siblings, 1 reply; 69+ messages in thread From: John Wilson @ 1998-08-25 4:00 UTC (permalink / raw) In article <6rukse$3q0$1@usenet01.srv.cis.pitt.edu>, Gregg E Economou <geest3+@pitt.edu> wrote: >thats not a feature of C. There is really only one data type in c: >memory. integers, pointers, floats, etc, theyre all just memory in C. >(thats the beauty of it). > Now, common proctice is that when you ant to store a string-like thing, >you terminate it with a null. but ther ei sno data type in C 'string' >which dictates a null terminated sequence of bytes. You can do _whatever_ you >want in C, which is why it is so nice, as opposed to languages where you _do_ >have a 'string' type perhaps, and have to live with the accompanying rstricitons >. The problem is cultural -- people tend to learn from other C programmers (either directly or by reading their code), so even if the language does allow writing good code, it's extremely common to see C code that assumes null-terminated strings (which BTW is part of the language since that's how string literals are stored -- you don't *have* to use it but it's a strong encouragement and it's what all the textbooks and magazine articles use). It's also common to run into C code that has few or no comments (and what comments there are often describe the obvious stuff but say nothing about the weird little tweaks in the code which are obviously working around some tricky problem but who knows what it is), doesn't check return codes, doesn't check buffer limits, and is in general, total crap code (but still works most of the time so no one cares). You don't *have* to write code like that, but many/most people do and the newbies are learning from these people so it's just getting worse. >as the famous quote goes, >C provides all the power of assembly with all the flexibility of assembly >*grin* A common belief among non-assembly programmers! John Wilson D Bit ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-25 4:00 ` John Wilson @ 1998-08-26 4:00 ` Gregg E Economou 1998-08-27 4:00 ` John Wilson 0 siblings, 1 reply; 69+ messages in thread From: Gregg E Economou @ 1998-08-26 4:00 UTC (permalink / raw) yes, but as i said- none of those are features of C per se, but of sloppy programmers, which can occur in any language. :) In article <35e2ffdf.0@news.wizvax.net>, John Wilson <wilson@dbit.com> wrote: >In article <6rukse$3q0$1@usenet01.srv.cis.pitt.edu>, >Gregg E Economou <geest3+@pitt.edu> wrote: >The problem is cultural -- people tend to learn from other C programmers >(either directly or by reading their code), so even if the language does >allow writing good code, it's extremely common to see C code that assumes >null-terminated strings (which BTW is part of the language since that's how >string literals are stored -- you don't *have* to use it but it's a strong okay, ill grant you that one, but it doesnt _force_ one to null-temrinate other text. its all a matter of convention, not absoluite necessity. <snip> >works most of the time so no one cares). You don't *have* to write code >like that, but many/most people do and the newbies are learning from these >people so it's just getting worse. > >>as the famous quote goes, >>C provides all the power of assembly with all the flexibility of assembly >>*grin* > >A common belief among non-assembly programmers! haha! well I program in several assemblies as well, and i do agree with you, but i still consider the above famous quote to be humourous and close enough to be worth posting. Many times ive wished i could inline while writing C when my compiler didnt support it!! > >John Wilson >D Bit happy hacking, gregg ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-26 4:00 ` Gregg E Economou @ 1998-08-27 4:00 ` John Wilson 0 siblings, 0 replies; 69+ messages in thread From: John Wilson @ 1998-08-27 4:00 UTC (permalink / raw) In article <6s1qp9$gm2$1@usenet01.srv.cis.pitt.edu>, Gregg E Economou <geest3+@pitt.edu> wrote: >>>C provides all the power of assembly with all the flexibility of assembly >>>*grin* >> >>A common belief among non-assembly programmers! > > haha! well I program in several assemblies as well, and i do agree with >you, but i still consider the above famous quote to be humourous and >close enough to be worth posting. >Many times ive wished i could inline while writing C when my compiler >didnt support it!! Ahh, but who would ever wish for the opposite? (Inlining C code into an assembly program!) John Wilson D Bit ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-25 4:00 ` Gregg E Economou 1998-08-25 4:00 ` Jordan Henderson 1998-08-25 4:00 ` John Wilson @ 1998-08-26 4:00 ` Bob Koehler 1998-08-27 4:00 ` Thor Lancelot Simon 1998-08-27 4:00 ` Peter da Silva 1998-08-26 4:00 ` Paul Sture 3 siblings, 2 replies; 69+ messages in thread From: Bob Koehler @ 1998-08-26 4:00 UTC (permalink / raw) In article <6rukse$3q0$1@usenet01.srv.cis.pitt.edu>, geest3+@pitt.edu (Gregg E Economou) writes: >thats not a feature of C. There is really only one data type in c: >memory. integers, pointers, floats, etc, theyre all just memory in C. >(thats the beauty of it). If you like that, you should be programming in BLISS. In any case it doens't justify C's poor string handling design. ---------------------------------------------------------------------- Bob Koehler | Computer Sciences Corporation Hubble Space Telescope Payload | Federal Sector, Civil Group Flight Software Team | please remove ".aspm" when replying ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-26 4:00 ` Bob Koehler @ 1998-08-27 4:00 ` Thor Lancelot Simon 1998-08-28 4:00 ` Bob Koehler ` (2 more replies) 1998-08-27 4:00 ` Peter da Silva 1 sibling, 3 replies; 69+ messages in thread From: Thor Lancelot Simon @ 1998-08-27 4:00 UTC (permalink / raw) In article <6s17hi$2g8@post.gsfc.nasa.gov>, Bob Koehler <koehler@bessta.gsfc.nasa.aspm.gov> wrote: > >In article <6rukse$3q0$1@usenet01.srv.cis.pitt.edu>, geest3+@pitt.edu (Gregg E Economou) writes: >>thats not a feature of C. There is really only one data type in c: >>memory. integers, pointers, floats, etc, theyre all just memory in C. >>(thats the beauty of it). > >If you like that, you should be programming in BLISS. In any case it >doens't justify C's poor string handling design. It's not a "design". It's a common convention among C programmers. If you want to use Pascal-format strings instead, you're perfectly free to -- without any of the intereference that a language that *didn't* understand that everything was, after all, just memory accessed with a different granularity, would give you. -- Thor Lancelot Simon tls@rek.tjls.com "And where do all these highways go, now that we are free?" ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-27 4:00 ` Thor Lancelot Simon @ 1998-08-28 4:00 ` Bob Koehler 1998-09-05 4:00 ` Peter da Silva 1998-08-28 4:00 ` TERENCE MURPHY 1998-08-31 4:00 ` Boris 2 siblings, 1 reply; 69+ messages in thread From: Bob Koehler @ 1998-08-28 4:00 UTC (permalink / raw) In article <6s4o0o$q31@news1.panix.com>, tls@panix.com (Thor Lancelot Simon) writes: >It's not a "design". It's a common convention among C programmers. > >If you want to use Pascal-format strings instead, you're perfectly free >to Sorry, but Mac C compilers are the only ones I've seen which support Pascal-format string constants. ANSI C calls for string constants which are null terminated. ---------------------------------------------------------------------- Bob Koehler | Computer Sciences Corporation Hubble Space Telescope Payload | Federal Sector, Civil Group Flight Software Team | please remove ".aspm" when replying ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-28 4:00 ` Bob Koehler @ 1998-09-05 4:00 ` Peter da Silva 1998-09-08 4:00 ` Carl Perkins 0 siblings, 1 reply; 69+ messages in thread From: Peter da Silva @ 1998-09-05 4:00 UTC (permalink / raw) In article <6s6dtu$d34@post.gsfc.nasa.gov>, Bob Koehler <koehler@bessta.gsfc.nasa.aspm.gov> wrote: >Sorry, but Mac C compilers are the only ones I've seen which support >Pascal-format string constants. ANSI C calls for string constants which >are null terminated. But sizeof() gives you the length even if it contains nulls. So you can do things like this: char *_string_(char *s, char l) { int i; for(i = 0; i<l; i++) s[i+1] = s[i]; s[0] = l; } #define PSTRING(s) _string_((s), sizeof(s)-1) There are disadvantages to pascal-style strings too... for example, they have a maximum length of 255 bytes. At the low level C operates, it's hard to pick a uniformally perfect format for strings... and at least you can work around it this way. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-09-05 4:00 ` Peter da Silva @ 1998-09-08 4:00 ` Carl Perkins 0 siblings, 0 replies; 69+ messages in thread From: Carl Perkins @ 1998-09-08 4:00 UTC (permalink / raw) peter@baileynm.com (Peter da Silva) writes... }There are disadvantages to pascal-style strings too... for example, they }have a maximum length of 255 bytes. At the low level C operates, it's hard }to pick a uniformally perfect format for strings... and at least you can }work around it this way. }-- }In hoc signo hack, Peter da Silva <peter@baileynm.com> That depends on the implementation. VAX Pascal allowed a string of any of the various types (other than "char" which is always 1 byte) to be up to 65,535 characters. (So says the help from the Pascal installed on some old VAXstations here, installed in about 1989 as I recall.) Newer implementaions relax that even more - Delphi, for example, allows strings to be as large as 4,294,967,295 characters each, since the length is a 32 bit unsigned integer. (Although Delphi may not fit a strict definition of Pascal, I suppose, but the newer versions of TurboPascal may have the same higher limit.) --- Carl ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-27 4:00 ` Thor Lancelot Simon 1998-08-28 4:00 ` Bob Koehler @ 1998-08-28 4:00 ` TERENCE MURPHY 1998-08-28 4:00 ` Monty Brandenberg ` (4 more replies) 1998-08-31 4:00 ` Boris 2 siblings, 5 replies; 69+ messages in thread From: TERENCE MURPHY @ 1998-08-28 4:00 UTC (permalink / raw) In article <6s4o0o$q31@news1.panix.com>, Thor Lancelot Simon <tls@rek.tjls.com> wrote: >It's not a "design". It's a common convention among C programmers. > >If you want to use Pascal-format strings instead, you're perfectly free >to -- without any of the intereference that a language that *didn't* >understand that everything was, after all, just memory accessed >with a different granularity, would give you. How do you propose I do this? Say I write a program: main() { char *hello = "Hello"; pascal_format_puts(hello); } How do I get the compiler to generate the hello string as a pascal string? Do compilers typically have a command line option to specify what kind of strings you can use? In particular, does gcc? It seems that the only semi-portable way to do this would be to compile the program with strings constants as writable, and convert each string a run-time. This is a serious, serious kludge, and I'd hardly say that this is a "perfectly free" task (especially since it is likely that many compilers do not even support writable string constants, so it's non-portable, which defeats the main purpose of C). Regards, Terry Murphy ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-28 4:00 ` TERENCE MURPHY @ 1998-08-28 4:00 ` Monty Brandenberg 1998-08-28 4:00 ` Greg Thomas ` (3 subsequent siblings) 4 siblings, 0 replies; 69+ messages in thread From: Monty Brandenberg @ 1998-08-28 4:00 UTC (permalink / raw) TERENCE MURPHY wrote: > > How do you propose I do this? Say I write a program: > > main() { char *hello = "Hello"; pascal_format_puts(hello); } > > How do I get the compiler to generate the hello string as a pascal > string? When using C, you have to do it with conventions and code discipline. On C/VMS, for example, the dsc$ structures are used to describe the various safe string types for use with the native VMS runtime libraries. But using them does rely on discipline. It doesn't provide true type safety. If you want that, you need to move to C++ or another strongly-typed language. -- Monty Brandenberg, Software Consultant MCB, Inc. mcbinc@ne.mediaone.net.MAPS.SPAM P.O. Box 426188 mcbinc@world.std.com.MAPS.SPAM Cambridge, MA 02142 617.864.6907 ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-28 4:00 ` TERENCE MURPHY 1998-08-28 4:00 ` Monty Brandenberg @ 1998-08-28 4:00 ` Greg Thomas 1998-08-29 4:00 ` mathog 1998-08-28 4:00 ` George Cornelius ` (2 subsequent siblings) 4 siblings, 1 reply; 69+ messages in thread From: Greg Thomas @ 1998-08-28 4:00 UTC (permalink / raw) On 28 Aug 1998 15:23:13 GMT, tsmurphy@cs.uiuc.edu (TERENCE MURPHY) wrote in article <6s6i11$jla$1@vixen.cso.uiuc.edu>: >How do you propose I do this? Say I write a program: > >main() { char *hello = "Hello"; pascal_format_puts(hello); } > >How do I get the compiler to generate the hello string as a pascal >string? Think of OpenVMS descriptors, and have a pascal_strings.h which contains ... typedef struct { unsigned int length; void *string_ptr; } pascal_string_t; #define pascal_string( variable, value )\ pascal_string_t variable = { strlen( value ), (void *)value }; void pascal_format_puts( pascal_string_t string ); Then you can have ... #include "pascal_string.h" main() { pascal_string( hello, "Hello" ); pascal_format_puts( hello ); } Greg -- This post represents the views of the author and does not necessarily accurately represent the views of BT. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-28 4:00 ` Greg Thomas @ 1998-08-29 4:00 ` mathog 1998-09-01 4:00 ` Greg Thomas 0 siblings, 1 reply; 69+ messages in thread From: mathog @ 1998-08-29 4:00 UTC (permalink / raw) In article <35fbd212.2154018254@news.axion.bt.co.uk>, thomasgd@omc.bt.co.uk (Greg Thomas) writes: > >Think of OpenVMS descriptors, and have a pascal_strings.h which >contains ... > > typedef struct > { > unsigned int length; > void *string_ptr; > } pascal_string_t; That stores the length, but does not store the maximum length, so you're still into buffer overrun land for safe_strcpy. Better would be: typedef struct { unsigned int storage_length; unsigned int length; void *string_ptr; } pascal_string_t; Where storage_length is either set at malloc() time, or if strings are packed into one big memory space, shortly thereafter. So it wastes a bit of space in the data, but might end up being more efficient in other ways. For instance status=safe_strcat(safe_string1,safe_string2); can check the sizes *before* it does anything, and then use a nice efficient loop to transfer one onto the end of the other. You call it, you know you're not going to get a buffer overrun. Unfortunately, null terminated strings permeate the libraries, so that you would probably have to resort to making all such strings one character longer than they would overwise be (storage_length - 1) so that you can pop a '\0' onto the end before calling printf (or whatever). That's still nasty though - what if somebody passes you a read only safe_string? To save the extra byte your safe_string.c module would have to implement dozens, and dozens of functions. That said, it would not be at all a bad idea to do so, since null terminated strings seem to be at the root of at least half the problems in C and C based operating systems. Regards, David Mathog mathog@seqaxp.bio.caltech.edu Manager, sequence analysis facility, biology division, Caltech ************************************************************************** * RIP VMS * ************************************************************************** ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-29 4:00 ` mathog @ 1998-09-01 4:00 ` Greg Thomas 0 siblings, 0 replies; 69+ messages in thread From: Greg Thomas @ 1998-09-01 4:00 UTC (permalink / raw) On 29 Aug 1998 00:18:21 GMT, mathog@seqaxp.bio.caltech.edu wrote in article <6s7hcd$sgs@gap.cco.caltech.edu>: > Better would be: > >typedef struct >{ > unsigned int storage_length; > unsigned int length; > void *string_ptr; >} pascal_string_t; > ... >Unfortunately, null terminated strings permeate the libraries, so that you >would probably have to resort to making all such strings one character >longer than they would overwise be (storage_length - 1) so that you can pop >a '\0' onto the end before calling printf (or whatever). ... Not necessarily. You could use, for example printf( "%.*s", string.length, string.string_ptr ); which will only display a maximum of string.length characters. Of course you then get into the debate of what happens if there is a NULL in the 'middle' of the string, so you might be better re-writing the printf() functions with your own to take this behaviour into account. Greg -- This post represents the views of the author and does not necessarily accurately represent the views of BT. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-28 4:00 ` TERENCE MURPHY 1998-08-28 4:00 ` Monty Brandenberg 1998-08-28 4:00 ` Greg Thomas @ 1998-08-28 4:00 ` George Cornelius 1998-08-29 4:00 ` Gregg E Economou 1998-09-05 4:00 ` Peter da Silva 4 siblings, 0 replies; 69+ messages in thread From: George Cornelius @ 1998-08-28 4:00 UTC (permalink / raw) In article <6s6i11$jla$1@vixen.cso.uiuc.edu>, tsmurphy@cs.uiuc.edu (TERENCE MURPHY) writes: > How do I get the compiler to generate the hello string as a pascal > string? Do compilers typically have a command line option to specify > what kind of strings you can use? In particular, does gcc? > > It seems that the only semi-portable way to do this would be to compile > the program with strings constants as writable, and convert each string > a run-time. This is a serious, serious kludge, and I'd hardly say that > this is a "perfectly free" task (especially since it is likely that > many compilers do not even support writable string constants, so it's > non-portable, which defeats the main purpose of C). As has been mentioned, the definition of a descriptor structure could be encapsulated in a macro and would result in painless generation of suitable string constants; and with an optimizing compiler the strlen() might actually be optimized away so that the run-time cost would be minimal. The effort involved in generating alternative string constants, even without this, turns out to be minor compared to writing and maintaining replacements to all the run-time routines that currently work with null-terminated strings only. May I suggest C++, or, better yet, Java, as the only reasonable way to write "C" code with safe strings? -- George Cornelius cornelius@eisner.decus.org cornelius@mayo.edu ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-28 4:00 ` TERENCE MURPHY ` (2 preceding siblings ...) 1998-08-28 4:00 ` George Cornelius @ 1998-08-29 4:00 ` Gregg E Economou 1998-09-05 4:00 ` Peter da Silva 4 siblings, 0 replies; 69+ messages in thread From: Gregg E Economou @ 1998-08-29 4:00 UTC (permalink / raw) hold on a sec! When the compiler sees this, heres what it does. In article <6s6i11$jla$1@vixen.cso.uiuc.edu>, >How do you propose I do this? Say I write a program: > >main() { char *hello = "Hello"; pascal_format_puts(hello); } > first, it sees the char declaration and generates a macro for allocating space at the stack. (or it generates the code itself) and investigates the ="hello" part to count how much space. On word-aligned systems or other such thing it figures out how much space to use. Then it ultimately generates some code which has the effect of pushing future stack references further by however much space was needed, and has the image (since this is after all a compiled-in literal) contain the 'hello' in the right place. |There is _nothing_ in the C compiler that understands that you wanted a string. This is because there is no such thing as a 'string' in the C compiler. When you use a library function like printf to display that 'hello' text, (in this case i am talking about how printf works but they all do somethign like it) , the function printf is called after putting the address of that bit of memory where the 'hello' started in a location that printf will search for its arguments. Usually printf will have its format string pointed to by a register and then either arguments pointed to by registers or else the next register will point to an array of pointers to arguments. that part is irrelevant. Printf, when told to print a string, will loop through the memory pointed to by its argument, where you told it there wa sa string, and printf will copy those bytes to the right place and have some other system calls or i/o calls get them printed out, and it will cease doing whatevver it takes to print them out when it sees one of them is zero (null). this is the closest you get to the undertsanding of a 'string' in this scenario. Your 'dependence' on a null-terminated 'string' "in C" is really the fact that printf is implemented to look for things like that when you tell it to print a string. It also reads its format string in that fashion. So really your dependence on 'strings' being null terminated is because the function (in this case printf) that you are choosing to use expects that when you are talking about 'strings' you mean 'a bunch of bytes consecutively found in memory the last of which is a null, beginning at some address'. Those people who things char*blorf makes blorf a string are misled- char*blorf really means that blorf is a pointer (the compiler will decide how much space is needed to store an address of the proper form for whatever system it is making code for) and that the amount of data that is nominally pointed to is one character, which C specifies to be no less tha eight bits in length. Since it is an address and no more, you could of course do somethin glike int* blarf; char*blorf=blarf; and be legal- but the char* declaration hints that wherever you actually refrence blorf in the source code, corresponding assembly or machine code will be generated which operates on the refrenced contents as a character, i.e. on some systems selecting instructons with byte operations as opposed to word or other such operations, on other systems invoking a mask and shift to operate on tthe value solely of this byte, and so on and so forth- it is a directive to hint at what you are referencing with this address and more than anything else is used to know how far down the stack one must read to retreive it. it means nothing about a string. In C there is no such thing as a string. There is memory. thats about all there is in C. integers, floats, and so on are all just directives to amounts of memory with a predetermined size. you could just as easily (though many compilers' preprocessors will complain or forbid this) use any other kind of pointer and treat it as a 'string' if you wished. However this would have some ramifications at compile time when things of different sizes were allocated and so on. oi! sorry to everyone for having to read this hideous ridiculosity, but for those who didnt know this stuff, now you do and now you know why a: there is no dependenceon any kind of data tye in C beyond the specifications that char be >7 bits long, int be >15 bits long, and long be >31 bits long. b: the concept of a 'string' in C is a convention which has persisted for many reasons but are all human factors in choosing to determine the end of some text in this manner. happy hacking, gregg >How do I get the compiler to generate the hello string as a pascal >string? Do compilers typically have a command line option to specify >what kind of strings you can use? In particular, does gcc? what do you mean by this? if youd liek to make a pascal string of this, then you have to create that structure somewhere. Your first step will probably be to count the size of the stuff that you would call a string that starts at the address contained in the location refrenced by hello, and then copy the data which begins at that address and continues to the length you detrermined into some other place in memory. Then you might continue by creating any further aspects of the structure you need, and then of course youd need an implementation of that print-a-pasca-string fucntion you wanted to call. If its in a library, call it and make sure it was declared or else extern'ed and either way linked in later. Then youd call it, using whatever means it needs to find the pascal string contruct in memory and oprate on it. > >It seems that the only semi-portable way to do this would be to compile >the program with strings constants as writable, and convert each string >a run-time. This is a serious, serious kludge, and I'd hardly say that >this is a "perfectly free" task (especially since it is likely that >many compilers do not even support writable string constants, so it's >non-portable, which defeats the main purpose of C). um, no, you are missing the entire point of C and its portability. C does NOT purport to provide some hideous monstrosity of massive strucutred langauges with heavy type enforcement. C is portable because NONE of that stuff is forced on the programmer. In C, the most important thing (and the only true data type) is a byte of memory. everythign else is some quantity of bytes of memory, and the other important thing of memory is the pointer. You have to know where in memory your stuff is. The second important thing in C aside form memory is logic and arithmetic. You do all that nifty stuff, including control flow and so on, and all the time you are performing your operations to process the contents of some locations of memory, ultimately storing your results somewhere (be it a register, or using some instruction to send data to the bus, or back to memory, is beyond the scope of this) and thus effecting some work done, which is the goal of any useful nontrivial program. the third thing you must consider with C is the possibility that you dont have all the memory at your disposal- things like other programs, and perhaps your own stack and so on, are places you should tread lightly, but are in no way bound to- you have the right and the means to destroy even yourself, or modify even yourself. now, many comilers will do all the fun of managing your stack, i mean after all thats part of its job, and many compilers have some macros built in for many things. There is part of C a macro facility, as well, which is of course the preprocessor defines and such. the preprocessor is part of a compilation facility but doesnt compile anything per se- it just processes the source code before compilation. Many people dont see the distinction well since other 'compilers' have incorporated this concept much more into the compilation stage and in many cases cannot be separated from it. Anyway, all the stuff like i/o and system calls and stuff, none of that is part of C itself. (regardless of whether ANSI calls the standard library a part of the language, it isnt. it is something which one can expect any ANSI C compiler to be able to support and operates as specified by the standard, but it is not part of the language but rather a set of routines written _in_ C which ANSI decided everyone should have at their disposal because of their widespready handiness and utility. ) At this point C looks like a nice way to mask the tedium of assembly rogramming wihtout giving up much of the direct control and without losing performance. All the higher-level stuff is implemented _in_ C, but is not _part_ of the language. Only the extreme simplicity of C itself the nlanguge, allos such higher level contructs to exist and work. I highly suggest the K&R book at this point before i have to start talking about structs and stuff... :) happy hacking, gregg ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-28 4:00 ` TERENCE MURPHY ` (3 preceding siblings ...) 1998-08-29 4:00 ` Gregg E Economou @ 1998-09-05 4:00 ` Peter da Silva 4 siblings, 0 replies; 69+ messages in thread From: Peter da Silva @ 1998-09-05 4:00 UTC (permalink / raw) In article <6s6i11$jla$1@vixen.cso.uiuc.edu>, TERENCE MURPHY <tsmurphy@cs.uiuc.edu> wrote: >It seems that the only semi-portable way to do this would be to compile >the program with strings constants as writable, and convert each string >a run-time. This is a serious, serious kludge, You want a kludge? Try this one: #define PSTRING(s) (""[0]=sizeof(s),(s)) Now *THAT* is a serious kludge. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "If Microsoft don't think you need it, it's not there and there's no 'U` way to include it yourself." -- Geoff Lane, a.s.r. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-27 4:00 ` Thor Lancelot Simon 1998-08-28 4:00 ` Bob Koehler 1998-08-28 4:00 ` TERENCE MURPHY @ 1998-08-31 4:00 ` Boris 2 siblings, 0 replies; 69+ messages in thread From: Boris @ 1998-08-31 4:00 UTC (permalink / raw) >If you want to use Pascal-format strings instead, you're perfectly free >to -- without any of the intereference that a language that *didn't* >understand that everything was, after all, just memory accessed >with a different granularity, would give you. You can use the best of both: Windows COM strings are Pascal-style but can be accessed as C-strings too. All it takes is to have strings NULL-terminated and have allocation function return pointer to text portion as opposed to header (size portion). Boris ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-26 4:00 ` Bob Koehler 1998-08-27 4:00 ` Thor Lancelot Simon @ 1998-08-27 4:00 ` Peter da Silva 1998-08-31 4:00 ` Boris 1 sibling, 1 reply; 69+ messages in thread From: Peter da Silva @ 1998-08-27 4:00 UTC (permalink / raw) In article <6s17hi$2g8@post.gsfc.nasa.gov>, Bob Koehler <koehler@bessta.gsfc.nasa.aspm.gov> wrote: >If you like that, you should be programming in BLISS. In any case it >doens't justify C's poor string handling design. String handling in a language that doesn't support dynamic memory management (including garbage collection!) is almost impossible to do "right". The best you can do is use a library. NONE of the libraries that were in use when the null termination convention was first developed are still in use (the closest, the Version 6 libc, was obsolete by 1980). If you don't like the way your library works, change it! Hell, I've worked on boxes where null terminated and counted strings were in concurrent use. It's not a big deal. -- In hoc signo hack, Peter da Silva <peter@baileynm.com> `-_-' "It takes 5 NT servers to offer the performance and availability 'U` of a single UNIX server" -- Network Computing, July 15 1998. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-27 4:00 ` Peter da Silva @ 1998-08-31 4:00 ` Boris 0 siblings, 0 replies; 69+ messages in thread From: Boris @ 1998-08-31 4:00 UTC (permalink / raw) >String handling in a language that doesn't support dynamic memory management >(including garbage collection!) is almost impossible to do "right". The best >you can do is use a library. Works great with C++: MFC CString, STL string<>, etc. Boris ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-25 4:00 ` Gregg E Economou ` (2 preceding siblings ...) 1998-08-26 4:00 ` Bob Koehler @ 1998-08-26 4:00 ` Paul Sture 1998-08-27 4:00 ` Gregg E Economou 3 siblings, 1 reply; 69+ messages in thread From: Paul Sture @ 1998-08-26 4:00 UTC (permalink / raw) Gregg E Economou wrote: > thats not a feature of C. There is really only one data type in c: > memory. integers, pointers, floats, etc, theyre all just memory in C. > (thats the beauty of it). > I have to disagree, as I distictly remember reading all about it in Kernighan and Ritchie's book on C. > >-- > >Paul Sture > >Z�rich > > > >paul dot sture at ubs dot com > > > > -- Paul Sture Z�rich paul dot sture at ubs dot com ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-26 4:00 ` Paul Sture @ 1998-08-27 4:00 ` Gregg E Economou 1998-08-28 4:00 ` Paul Sture 0 siblings, 1 reply; 69+ messages in thread From: Gregg E Economou @ 1998-08-27 4:00 UTC (permalink / raw) But it is a convention, yes convention since the beginning, yes the string handling libraries all assume a null-terminated string, but you could just as easily use some other means of representing ASCII text. Just about the only real assumptions about the machine that C has a hard time living without is the existence od an 8-bit byte and a byte-addressable memory system. And even those you can work around. K&R did set the convention on null-terminated strings, and it is rational enough, and very flexible, as something which illustrates a higher-level construct existing in the onctext of C wihtout being a part of the actual language. Certainly there are times when null-termination on strings can be a pain, and at those times some small management and explicitly sized buffers can be maintained to keep track of it, or whatever. you're not _bound_ to null-terminated text in C! happy hacking, gregg In article <35E3FB05.1B94F00E@ubs.com>, Paul Sture <paul.sture@ubs.com> wrote: > >I have to disagree, as I distictly remember reading all about it in Kernighan and >Ritchie's book on C. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * 1998-08-27 4:00 ` Gregg E Economou @ 1998-08-28 4:00 ` Paul Sture 0 siblings, 0 replies; 69+ messages in thread From: Paul Sture @ 1998-08-28 4:00 UTC (permalink / raw) Gregg E Economou wrote: > But it is a convention, yes convention since the beginning, > yes the string handling libraries all assume a null-terminated string, > but you could just as easily use some other means of representing ASCII > text. Thanks for the clarification. I had thought "that is the way it is", rather than a convention. > K&R did set the convention on null-terminated strings, and it is rational > enough, and very flexible, as something which illustrates a higher-level > construct existing in the onctext of C wihtout being a part of the actual > language. To be honest, I don't really like the concept of null-terminated strings, and prefer counted or fixed-length ones. If I'd ever logged all the bugs I've fixed, an analysis of that log would probably spell out a big NO to null-terminated strings. > Certainly there are times when null-termination on strings can be a pain, > and at those times some small management and explicitly sized buffers > can be maintained to keep track of it, or whatever. you're not _bound_ to > null-terminated text in C! Yup. Having successfully managed to avoid much C over the years, you have just demolished one of my excuses<grin> -- Paul Sture Z�rich paul dot sture at ubs dot com ^ permalink raw reply [flat|nested] 69+ messages in thread
end of thread, other threads:[~1998-09-09 4:00 UTC | newest]
Thread overview: 69+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <0095000017115526000002L062*@MHS>
[not found] ` <35E04DF1.1911@world.std.com>
[not found] ` <35E09E76.6773@earthlink.net>
1998-08-23 4:00 ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Terry C. Shannon
1998-08-23 4:00 ` Glenn C. Everhart
1998-08-24 4:00 ` Paul Sture
1998-08-25 4:00 ` Gregg E Economou
1998-08-25 4:00 ` Jordan Henderson
1998-08-26 4:00 ` Bob Koehler
[not found] ` <6s910k$2bo$1@Starbase.NeoSoft.COM>
[not found] ` <35e833be.0@news.wizvax.net>
1998-08-29 4:00 ` Jordan Henderson
1998-08-30 4:00 ` John Wilson
1998-08-30 4:00 ` JF Mezei
1998-08-30 4:00 ` Chris Torek
1998-08-31 4:00 ` Gregg E Economou
1998-08-31 4:00 ` Chris Torek
1998-08-30 4:00 ` Lawrence Kirby
1998-08-30 4:00 ` JF Mezei
1998-08-30 4:00 ` Martin Ambuhl
[not found] ` <6scur7$qtk@bgtnsc02.wo <35EA0E22.C59E9476@videotron.ca>
1998-08-31 4:00 ` Will Rose
1998-08-31 4:00 ` Michael Rubenstein
1998-08-31 4:00 ` Craig Franck
1998-08-30 4:00 ` JF Mezei
1998-08-31 4:00 ` firewind
1998-09-04 4:00 ` Thor Lancelot Simon
1998-08-30 4:00 ` Gregg E Economou
1998-08-30 4:00 ` K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) Clint Comes
1998-08-31 4:00 ` Bob Koehler
1998-09-05 4:00 ` Gregg E Economou
1998-09-05 4:00 ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Peter da Silva
1998-09-05 4:00 ` Jordan Henderson
1998-09-07 4:00 ` Peter da Silva
1998-09-07 4:00 ` Jordan Henderson
1998-09-07 4:00 ` Peter da Silva
1998-09-07 4:00 ` Jordan Henderson
1998-09-08 4:00 ` Tim Shoppa
[not found] ` <6t4cui$hfu@espresso.cafe.net>
1998-09-09 4:00 ` Tim Shoppa
1998-09-08 4:00 ` JF Mezei
1998-09-09 4:00 ` Dan Pop
1998-09-09 4:00 ` Peter da Silva
1998-09-08 4:00 ` Peter da Silva
[not found] ` <6t2im5$mke@espresso.cafe.net>
1998-09-08 4:00 ` Peter da Silva
1998-09-08 4:00 ` Peter da Silva
1998-09-08 4:00 ` JF Mezei
1998-09-08 4:00 ` Dan Pop
1998-09-08 4:00 ` Peter da Silva
1998-09-08 4:00 ` Dan Pop
1998-09-07 4:00 ` Richard Stamp
1998-09-07 4:00 ` Dan Pop
1998-08-29 4:00 ` Gregg E Economou
1998-08-30 4:00 ` Jay Maynard
1998-08-25 4:00 ` John Wilson
1998-08-26 4:00 ` Gregg E Economou
1998-08-27 4:00 ` John Wilson
1998-08-26 4:00 ` Bob Koehler
1998-08-27 4:00 ` Thor Lancelot Simon
1998-08-28 4:00 ` Bob Koehler
1998-09-05 4:00 ` Peter da Silva
1998-09-08 4:00 ` Carl Perkins
1998-08-28 4:00 ` TERENCE MURPHY
1998-08-28 4:00 ` Monty Brandenberg
1998-08-28 4:00 ` Greg Thomas
1998-08-29 4:00 ` mathog
1998-09-01 4:00 ` Greg Thomas
1998-08-28 4:00 ` George Cornelius
1998-08-29 4:00 ` Gregg E Economou
1998-09-05 4:00 ` Peter da Silva
1998-08-31 4:00 ` Boris
1998-08-27 4:00 ` Peter da Silva
1998-08-31 4:00 ` Boris
1998-08-26 4:00 ` Paul Sture
1998-08-27 4:00 ` Gregg E Economou
1998-08-28 4:00 ` Paul Sture
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox