From ... From: Erik Naggum Subject: Re: Allegro CL foreign function interface Date: 2000/06/15 Message-ID: <3170063668357994@naggum.no>#1/1 X-Deja-AN: 634873993 References: <86zooo43i5.fsf@mypp.consela.com> <86u2ewyu2c.fsf@mypp.consela.com> <3170000943482820@naggum.no> mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 961075206 5050 195.0.192.66 (15 Jun 2000 13:20:06 GMT) Organization: Naggum Software; vox: +47 8800 8879; fax: +47 8800 8601; http://www.naggum.no User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.6 Mime-Version: 1.0 NNTP-Posting-Date: 15 Jun 2000 13:20:06 GMT Newsgroups: comp.lang.lisp * "Sandeep Koranne" | Maybe I have not understood your comment correctly, but it seems to | me that C/C++ main fiunction does NOT get a zero terminated vector | (a vector by definitin is a single dimension array) while in C/C++ | the arguments to main are, int main (int argc, char* argv[]) : or a | vector or vectors. So we DO need both the count of argument and the | Vector of Vectors (the elements of argv are of course ZERO | terminated strings). C's conventional variable-sized vector representation is that (aref (length )) => nil to put it in more familiar terms, and this holds for all vectors of all types, with varying representations of nil, of course, but they are generally just warped versions of the integer 0, which is, of course, just a convenient bit pattern of all zeros. A string has a character conflatable with the integer 0, the NUL, and a vector of any pointer type has a void * conflatable with the integer 0, the NULL. So it may be more proper to say "NULL-terminated" than "zero- terminated", although the semantics of NULL is strictly that of a machine representation of zero. Let's not give C any more credit than it deservers, is my line. The count is in fact unnecessary, as witnessed by the fact that the exec* family of system calls actually transmit only the variable- sized vector of arguments and optionally environment bindings to the kernel, which transmits them as such to the C runtime library, which _then_ traverses the argument list and counts the arguments and passes them to the main function with a count, for convenience. I happen to think that this count-as-well-as-null-termination thing is one of C's fundamentally braindamaged design decisions, having caused an enormous amount of problems for programmers who don't get the idea that it's a sometime convenience, not a pattern to learn by rote and repeat uncritically, no matter how counter-productive. #:Erik -- If this is not what you expected, please alter your expectations.