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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: a new language, designed for safety ! Date: Fri, 06 Jun 2014 21:39:41 +0300 Organization: Tidorum Ltd Message-ID: References: <3bf7907b-2265-4314-a693-74792df531d1@googlegroups.com> <51e9fd4f-e676-4d2f-9e21-1c782d71092e@googlegroups.com> <5391ffa4$0$6611$9b4e6d93@newsspool4.arcor-online.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net 0+nyRk2h0WW3Hlwg+jGBXAN/ffzrjz/aDl5t4g/Hza/WpTV1+U Cancel-Lock: sha1:Ol47vaZVD4yoQ46NXZb2SW+r/c8= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: <5391ffa4$0$6611$9b4e6d93@newsspool4.arcor-online.net> X-Original-Bytes: 4131 Xref: number.nntp.dca.giganews.com comp.lang.ada:186769 Date: 2014-06-06T21:39:41+03:00 List-Id: On 14-06-06 20:51 , G.B. wrote: > On 06.06.14 17:13, Dan'l Miller wrote: >> If a fatal runtime error due to an unimplemented method (which Ada >> would catch at compile-time, but Swift & Objective-C would catch only >> at runtime [ snip ] > > Since Ada programs may well have "unimplemented methods", [ snip ] > Because, with regard to dispatching, if an Ada programmer > decides to use run-time dispatching, then there may well be > run-time errors. These include calling an undefined primitive > operation of a tagged type. This is demonstrated below. I think the error in your example is of a different kind. > The program fails predictably, even though it does not use > pointers or tricks. > > $ ./comptime > > raised CONSTRAINT_ERROR : comptime.ada:35 tag check failed > $ > > That's a run-time error, I'd say, stopping the program. Yes. > The state of P2.Op being unimplemented is announced in source, > though, ("abstract") which is different from just absence > as in Objective-C etc. This is not the error in your program. > package Pak is > > pragma Pure (Pak); > > package P1 is > type A is abstract tagged private; > procedure Op (X : in out A) is abstract; > private > type A is abstract tagged null record; > end P1; > > package P2 is > type T is new P1.A with private; > overriding procedure Op (X : in out T); > private > type T is new P1.A with null record; > end P2; > > package P3 is > -- Drills a hole! No. > type TA is abstract new P2.T with private; > overriding procedure Op (X : in out TA) is abstract; > private > type TA is abstract new P2.T with null record; > end P3; > > end Pak; > > with Pak; > procedure Comptime > is > Obj : Pak.P2.T; > X : Pak.P1.A'Class := Obj; > begin > Pak.P3.TA'Class(X).Op; -- run-time dispatching The error, as I understand it, is trying to convert X, which is of a classwide type covering Pak.P2.T, to a classwide type (Pak.P3.TA'Class) which does not cover Pak.P2.T. (Apologies if I'm not using the correct ARM terms for this.) The dispatching call is not the problem. This error is more similar to a subtype or type conversion error, where the source value violates the constraints of the target type. Yes, Ada has run-time errors, but they are not the result of "unimplemented methods". An example coming closer to an unimplemented method error would, IMO, be a run-time dispatch to an operation with two or more controlling parameters, where the actual parameters have different tags, and there is no operation for this mixture of tags (of course, as Ada does not permit such multiple dispatch). -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .