From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,635cd9622b25ae59 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!j33g2000cwa.googlegroups.com!not-for-mail From: "REH" Newsgroups: comp.lang.ada Subject: Re: Type safety, C++ and code generation Date: 27 Apr 2006 07:47:49 -0700 Organization: http://groups.google.com Message-ID: <1146149268.981471.31810@j33g2000cwa.googlegroups.com> References: <1146143954.169807.207080@t31g2000cwb.googlegroups.com> NNTP-Posting-Host: 192.35.35.34 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1146149274 31845 127.0.0.1 (27 Apr 2006 14:47:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 27 Apr 2006 14:47:54 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j33g2000cwa.googlegroups.com; posting-host=192.35.35.34; posting-account=lnUIyw0AAACoRB2fMF2SFTIilm8F10q2 Xref: g2news2.google.com comp.lang.ada:3956 Date: 2006-04-27T07:47:49-07:00 List-Id: Maciej Sobczak wrote: > REH wrote: > > >>http://www.msobczak.com/prog/typegen/ > > > You maybe interested in a C++ class that I wrote. > > Been there, done that: > > http://www.msobczak.com/prog/downloads.html > > (see safetypes.tar.gz and range.tar.gz) > > I have dropped this idea because I think that the external code > generator is much more flexible and more powerful with regard to the > type safety that can be gained. Range checking is just one little part > of what is needed. Template classes are fine if you can afford limiting > yourself only to this little part, but that's not usually the case. > > > -- I just took a look at the code to pointed to above. It is much different then mine: 1) yours allows for undefined behavior by not checking for overflows before doing the operations. 2) yours does not eliminate unnecessary checks. 3) yours does not allow intermidate results to exceed the bounds of the range. For example, given a variable x, with a range of [0, 100], yours will fail on x = (x * 1000) / 1000, mine will not. 4) yours does not allow for types larger than long, such as unsigned long or implementation-specific types such as long long. 5) yours does not check for division-by-zero. Think you are being dismissive without even looking at it. REH