From 2905932783456522361 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,6d203f57726a4ad8 X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2003-01-09 10:42:49 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull From: thp@cs.ucr.edu Newsgroups: comp.std.c++ Subject: Re: Intelligent subscript checking Date: Thu, 9 Jan 2003 18:42:44 +0000 (UTC) Organization: University of California, Riverside Lines: 63 Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: References: <3E081F9B.3090409@nycap.rr.com> <26fabedc.0301080212.14b8d54e@posting.google.com> <3E1C87E8.70409@animats.com> <3e1cd189@news.toast.net> X-Trace: mail2news.demon.co.uk 1042137764 552 10.0.0.1 (9 Jan 2003 18:42:44 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 9 Jan 2003 18:42:44 +0000 (UTC) X-Received: from mulga.cs.mu.oz.au ([128.250.1.22]) by news.demon.co.uk with esmtp (Exim 4.05) id 18Whdb-00008b-00 for mail2news@news.news.demon.net; Thu, 09 Jan 2003 18:42:43 +0000 X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU id FAA17190; Fri, 10 Jan 2003 05:42:35 +1100 (EST) X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Path: comp-std-cpp-robomod!not-for-mail X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Delivered-To: std-c++@ncar.ucar.edu X-Newsgroups: comp.std.c++ X-NNTP-Posting-Date: Thu, 9 Jan 2003 09:22:24 +0000 (UTC) X-User-Agent: tin/1.5.14-20020926 ("Soil") (UNIX) (Linux/2.4.20-xfs (i686)) X-MailScanner: PASSED (v1.2.7 46199 h099oUmj046672 mailbox6.ucsd.edu) X-Spam-Status: No, hits=-5.1 required=5.0 tests=INVALID_MSGID,NOSPAM_INC,NO_REAL_NAME,REFERENCES, SPAM_PHRASE_00_01,USER_AGENT version=2.41 Xref: archiver1.google.com comp.std.c++:16947 "Scott Mayo" wrote: + "John Nagle" wrote in message + news:3E1C87E8.70409@animats.com... + +> The big problem with C is that the compiler doesn't +> know about arrays. I'd argue that it's time for +> C++ compilers to know more about the STL, so that +> they can check arrays. +> +> Here's a good start: I'd like to have "assert", +> or something like "assert", known to the compiler, +> with the following semantic rule: +> +> "An assertion can be reported as failing as soon +> as its failure becomes inevitable." + ... +> vector tab(100); +> int j; +> // j gets assigned some value +> for (int i=0; i < j; i++) +> { tab[i] = 0; } // ... code not including break, return, or +>assignment to i } +>The loop gets expanded into +> for (int i=0; i < j; i++) +> { assert(i >= 0); +> assert(i < tab.size()); +> tab[i] = 0; +> } + + + These are interesting ideas, but I don't believe they are C++. + They belong to C++'s offspring, to some much higher level + language in which there is no implicit guarantee that any + statement reduces to the minimum, obvious hardware + operations. "Everyone knows", to pirate your example, that + for (i=0;i