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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,604e0f87aa06eab6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-24 10:33:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!logbridge.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!uunet!dca.uu.net!ash.uu.net!spool0900.news.uu.net!reader0902.news.uu.net!not-for-mail Date: Mon, 24 Mar 2003 13:33:13 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030313 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Imitation is the sincerest form of flattery References: <1047665830.579605@master.nyc.kbcfp.com> <7eee7v4hpvj0i5s345uonlen5315rhiau8@4ax.com> <4dkea.75440$gi1.38045@nwrdny02.gnilink.net> <1048524746.273345@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1048530794.5794@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1048530795 reader2.ash.ops.us.uu.net 9676 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:35658 Date: 2003-03-24T13:33:13-05:00 List-Id: Dmitry A. Kazakov wrote: > First of all, there is no contract. I want the compiler be > aware that it is going to be an array and check if it is. You have proxy classes that deal with all of this stuff. Everything is typechecked. > Secondly to make A[i]=X working you have to use a reference. Now, let I a > have a packed bit array. What would be a reference to a bit? You would need > to build a fat pointer class to fix this. The array has to represent an > image in the video buffer. It has to be damn FAST. And where are > multidimensional arrays in C++? And where are slices? Well, for them we > need another class, etc. And what if A is a hash table, sparse array. It > would be monstrous. And I want it on the stack! It's not monstrous at all. First of all, as an Ada programmer, you should not be complaining about having to write extra lines of code to do what you want, as long as its all nice and readable. Second of all, just because you need classes to handle all of this doesn't prevent things from being on the stack, or from being fast. Third of all, there is plenty of existing code to do this sort of thing, in Boost and elsewhere. Remembering some of our previous threads, I would caution you that the proper way to implement all of this will eschew inheritance and use templates heavily. If you try to do this using OO, then yes, your code will be miserably slow. > IMO. The idea of treating > A[i]=X; > as > Assign (Index (A, i), X); > is a wrong one. Why? In particular, this technique is used very often in C++, especially with expression templates. One has Index(A,i) just return a proxy class which holds A and i, and implements the Assign to take such a class. Inline expansion does the rest, usually resulting in code that looks like an open-coded version.