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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9d303864ae4c70ad X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-10 03:49:33 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!dialin-145-254-036-234.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Reprise: 'in out' parameters for functions Date: Sat, 10 Apr 2004 12:49:17 +0200 Organization: At home Message-ID: References: <5ad0dd8a.0404090512.15af2908@posting.google.com> <5ad0dd8a.0404091828.6e79bb4e@posting.google.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-036-234.arcor-ip.net (145.254.36.234) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 1081594172 94936458 I 145.254.36.234 ([77047]) User-Agent: KNode/0.7.2 Xref: archiver1.google.com comp.lang.ada:6941 Date: 2004-04-10T12:49:17+02:00 List-Id: Wojtek Narczynski wrote: >> I take it Ada forces abstraction in version in cases? >> Could you name an example unit to look at? > > 'Inversion' not 'in version' incase it were more than a typo. When you > implement a semaphore over a protected object, or in general when you > need to lock / unlock by yourself. Classic example: > > polyorb-tasking-profiles-full_tasking-mutexes.adb > > Or try to implement tree crabbing. Hell, try to implement a list > updateable concurrently from multiple tasks. You _will_ end up > implementing a semaphore over a protected, over a semaphore. > > Or the simplest possible: two protected counters, try to get the sum > atomically. This has nothing to do with abstraction inversion. The problem here is that Ada does not have multiple protected actions. Same problem with tasks, there cannot be rendezvous with multiple tasks. It is much work to solve that. Especially to convince people that prefix notation is inherently bad. >> : type system unable >> : to express physical units, >> >> Still, you might have >> >> type Quantity is abstract tagged private; >> >> function in_meters (x: Quantity) return Units.meter; >> function in_yards (x: Quantity) return Units.yard; >> -- etc... > > Sure, let us continue: > > function in_kilograms (x: Quantity) return Units.yard; > -- Blows at runtime > > This just cannot be done right in Ada. This is wrong: http://home.t-online.de/home/Christ-Usch.Grein/Ada/Dimension.html The type system is capable to express dimensioned units. The major problem here is not the type system, but inability to get rid of statically known discriminants, which makes an implementation inefficient. >> : But the problem real problem IMO is that >> : the development of the language has stagnated. >> >> What's missing? > > From the language? For example parameters for exceptions. How they could have parameters? There are only two ways for dealing with exceptions. Either 1) all of them are of one [specific] type (maybe an implicit one) or 2) they are of different types (maybe rooted in the same root type [class-wide approach]). Ada has 1), which excludes parameters. If you think that 2) would be better for Ada then solve the following: generic package Crazy is type Virtual is new Exception with ...; -- Note that Virtual exists in an instance of Crazy only. -- It is finalized together with the instance. procedure Show_Me (Object : Virtual); end Crazy; package body Crazy is Local : Integer := 0; procedure Show_Me (Object : Virtual) is begin Put_Line (Integer'Image (Local)); end Show_Me; begin raise Virtual (your fine parameters); end Crazy; declare package Catch_It is new Crazy; begin null; exception when Error : others => -- What sort of type has Error? -- Can I dispatch to Show_Me? -- What it will print? -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de