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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsprint.newsread.com!newsread.com!news-xfer.newsread.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!newsmst01a.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr13.news.prodigy.com.POSTED!4988f22a!not-for-mail From: Newsgroups: comp.lang.ada,comp.lang.c++ References: <1110329098.642196@athnrd02> <1110361741.551255@athnrd02> <422edaec$0$26554$9b4e6d93@newsread4.arcor-online.net> <1111464133.508323@athnrd02> <423fe9df$0$11476$9b4e6d93@newsread2.arcor-online.net> <1111521825.653841@athnrd02> <424094b0$0$11481$9b4e6d93@newsread2.arcor-online.net> <1111568404.687226@athnrd02> <1111572591.296439@athnrd02> <1111574207.72969@athnrd02> <42414f88$0$9217$9b4e6d93@newsread4.arcor-online.net> <1111576802.823362@athnrd02> <1111577078.934620@athnrd02> <1111586334.958702.249050@o13g2000cwo.googlegroups.com> <1111608867.922129@athnrd02> <1111631889.495954@athnrd02> <1111634628.927041@athnrd02> Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: <7vD0e.1102$zl.687@newssvr13.news.prodigy.com> NNTP-Posting-Host: 64.164.117.46 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr13.news.prodigy.com 1111688259 ST000 64.164.117.46 (Thu, 24 Mar 2005 13:17:39 EST) NNTP-Posting-Date: Thu, 24 Mar 2005 13:17:39 EST Organization: SBC http://yahoo.sbc.com X-UserInfo1: TSU[@SBEQJV]SQ@[EZOD]_\@VR]^@B@MCPWZKB]MPXHTEPIB_NVUAH_[BL[\IRKIANGGJBFNJF_DOLSCENSY^U@FRFUEXR@KFXYDBPWBCDQJA@X_DCBHXR[C@\EOKCJLED_SZ@RMWYXYWE_P@\\GOIW^@SYFFSWHFIXMADO@^[ADPRPETLBJ]RDGENSKQQZN Date: Thu, 24 Mar 2005 18:17:39 GMT Xref: g2news1.google.com comp.lang.ada:9921 comp.lang.c++:47100 Date: 2005-03-24T18:17:39+00:00 List-Id: "Ioannis Vranos" wrote in message news:1111634628.927041@athnrd02... > > Since I have had enough with this signed value range of Ada, here is a > quick implementation of mine and some uses of it. > Are you under the illusion that the code [your code included below] is actually expressive? About forty years ago, when I was working in a Fortran shop, we were awarded a contract for an inventory management system. At that time, we were mostly focused on missile defense software, but our DoD customer was persuaded by our marketing people that we could do the job. An argument ensued in our programming group about what language to use. I was trying to convince my colleagues that we should use COBOL since, at that time, it was the dominant language for business applications. In my view, COBOL best expressed the kind of solutions we needed for the problem at hand. Many of my colleagues were adamant about Fortran. Each example I gave of how something would be done in COBOL, they countered with an example of how it "could" be done in Fortran. As this debate continued, some of the Fortran solutions began to look more and more bizzare. Our manager finally concluded, correctly, that the problem could best be solved in COBOL. >From this experience, I concluded that there were two important considerations in language selection: 1) how well does this language express the kind of solutions required for the problem to be solved, and 2) is it possible to solve the problem using a given language, even it the solution is a little ugly? The first I called expressiveness. The second I called expressibility. In the years since then, others have come to similar views and that is why new languages are designed from time to time. A solution to almost any programming problem can be expressed in almost any language. This is expressibility. When a language allows one to express that solution with concisely and with ease, that is expressiveness. Expressible? Expressive? Which is more appropriate for solving problems? While you solution demonstrates expressibility, it fails to meet the test of expressiveness. I admit that one must be a little careful when using the expressiveness test in evaluating a language design. Some expressive syntax might be expressive, but fail other tests. For example, the popular, += *= and other operator= constructs of the C family of language are wonderfully expressive of a simple idea, but their use fails the test of compile-time confirmability. That is, they are highly expressive but some of them are also error-prone. The example from Ada, type Index is range -42 .. 453; is confirmable every place it is used. It is expressive of a simple idea. It does not involve any unusual behavior at any point in the program where it is used. It can be checked by the compiler for validity. It can raise run-time errors without the programmer inserting specialized code. It is expressive of the idea of a static range of values for a named type. No doubt that, when you evaluate your solution in the context of expressiveness versus expressibility, you will see the difference. ------------------------------------------------------------------------------ > I am sure one can create a better one or a container directly that > supports ranges, if he devotes some time, so the question again arises, > since it is possible and nothing exists, probably it is not considered > useful to have such a feature in C++: > > > #include > #include > #include > > template > class range > { > std::vector array; > T min, max; > > public: > range(const T &mi, const T &ma):array(ma-mi+1), min(mi), max(ma) > { > using namespace std; > > if(max-min<=0) > ;//throw some exception > > for(typename vector::size_type i=0; i array[i]=min+i; > } > > const T &operator[](const T &index) > { > // Add range checking max>=index>=min if desirable > > return array[index-min+1]; > } > > operator T() { return array.size(); } > > }; > > > int main() > { > using namespace std; > > range r(-100, -20); > > vector vec(r); > > vec[r[-65]]=3; > } > > > > > -- > Ioannis Vranos > > http://www23.brinkster.com/noicys