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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no 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-25 07:53:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!news-in.nuthinbutnews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny01.gnilink.net.POSTED!53ab2750!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <7eee7v4hpvj0i5s345uonlen5315rhiau8@4ax.com> <4dkea.75440$gi1.38045@nwrdny02.gnilink.net> <5115eb96.0303220201.44527637@posting.google.com> <5115eb96.0303232053.2fcc7d78@posting.google.com> <5115eb96.0303242148.57027600@posting.google.com> Subject: Re: Imitation is the sincerest form of flattery X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: <6Y_fa.5102$kU.534@nwrdny01.gnilink.net> Date: Tue, 25 Mar 2003 15:53:38 GMT NNTP-Posting-Host: 141.157.180.238 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny01.gnilink.net 1048607618 141.157.180.238 (Tue, 25 Mar 2003 10:53:38 EST) NNTP-Posting-Date: Tue, 25 Mar 2003 10:53:38 EST Xref: archiver1.google.com comp.lang.ada:35687 Date: 2003-03-25T15:53:38+00:00 List-Id: "Amir Yantimirov" wrote in message news:5115eb96.0303242148.57027600@posting.google.com... > Not that. I propose something alike this: > > type TFoo = record ... end record; > > procedure Bar ( Baz : in out TFoo); > with TFoo: > 'First = 1; > 'Last = 32; > [].Read = ReadBits; > [].Write = WriteBits; > end with; > begin > Baz[40] := 0; -- compile error! I'm a little confused by this pseudo-code. Is Bar a derived type? Is it some sort of constructor? And what does the "[].Write = WriteBits;" statement do? You may very well have a quite valuable idea here, but this code sample does not convey it. Now that you have piqued our curiousity, please clarify. > Different levels of abstraction needs different solutions. So I argue > only that ALL types should be tagged. In a sense, you're absolutely right. The most consistent way to do OOP is to allow a type hierarchy to be based on any type, including built-in scalar types. An example of this is the Smalltalk language. Everything in Smalltalk is part of a class hierarchy, including boolean values, integers, characters, and even blocks of code. Smalltalk's consistent "everything is an object" approach is elegant and provides unparalleled ability to apply OOP techniques. There is only one good reason, why Ada, C++, C# and Java have not adapted the Smalltalk philosophy of having everything tagged: efficiency. Smalltalk, for all of its virtues, has been terribly slow due to its need to use indirection for nearly everything. Consider this: type My_Integer is new Integer; function "+" ( Left, Right : in My_Integer ) return My_Integer; function "*" ( Left, Right : in My_Integer ) return My_Integer; -- ... -- Currently not valid Ada, but this would be valid if Integer is tagged. procedure Compute( A, B : in Integer'Class ) is begin -- ... end Compute; Within Compute, arithmetic with A and B will depend on whether they are Integer or My_Integer. As desirable as this may be, this certainly rules out using the implicit versions of "+" and "*". A call to Compute would require that, somehow, tags be attached to A and B. This requirement is why we have the annoying boxing and unboxing stuff in C#. If there is a way to get the effect of tagged scalar types without a big hit on efficiency, however, it would certainly be helpful. Perhaps there is some happy compromise between Smalltalk and C#.