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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,604e0f87aa06eab6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-25 23:32:53 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: amir@iae.nsk.su (Amir Yantimirov) Newsgroups: comp.lang.ada Subject: Re: Imitation is the sincerest form of flattery Date: 25 Mar 2003 23:32:52 -0800 Organization: http://groups.google.com/ Message-ID: <5115eb96.0303252332.3fabaad2@posting.google.com> References: <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> <6Y_fa.5102$kU.534@nwrdny01.gnilink.net> NNTP-Posting-Host: 81.1.215.198 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1048663973 27776 127.0.0.1 (26 Mar 2003 07:32:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 26 Mar 2003 07:32:53 GMT Xref: archiver1.google.com comp.lang.ada:35710 Date: 2003-03-26T07:32:53+00:00 List-Id: "Frank J. Lhota" wrote in message news:<6Y_fa.5102$kU.534@nwrdny01.gnilink.net>... > "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. It is a poor attempt to show how can looks addition of array interface with fixed index bounds (so compiler can do range check) to already defined type and inside some scope (procedure Bar). I never used Ada and attempt to make example looks Ada-like only adds confusion. The previous poster wrote that extending of type interface exist only in dynamic languages as Smalltalk and don't allow compile time checks and I tried to show that (theoretically) compiler is capable to do this statically if necessary information is provided. More of that here: http://www174.pair.com/yamir/programming/interfaces.htm In a short, I think it is a serious restriction that we use one language construct (type/class) for description of two completely different things - concrete information storage and abstract behaviour interface. Amir Yantimirov