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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c7c302806c75a91b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Received: by 10.66.78.161 with SMTP id c1mr36815pax.16.1351874733217; Fri, 02 Nov 2012 09:45:33 -0700 (PDT) Received: by 10.68.234.41 with SMTP id ub9mr591437pbc.11.1351874733203; Fri, 02 Nov 2012 09:45:33 -0700 (PDT) Path: s9ni74817pbb.0!nntp.google.com!kr7no29411322pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 2 Nov 2012 09:45:33 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Design by contract and control inversion From: Shark8 Injection-Date: Fri, 02 Nov 2012 16:45:33 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-11-02T09:45:33-07:00 List-Id: On Wednesday, October 31, 2012 1:28:33 PM UTC-6, Hibou57 (Yannick Duch=EAne= ) wrote: > Hi all, >=20 > I wondered if there are known idioms to express predicates for callbacks,= =20 > which may be via access to subprogram or interface/tagged types. Hm, it seems to me that you could have an intermediate/pass-through handler= . (It would be rather limited, unless you make pre-/post-condition parameters= ... and if you do that it could get cumbersome quick.) [NOTE: Not compiled or checked, just brainstorming/psudocode.] Type Obj_Handle is not null access Object'class; Type Handler is Access Procedure ( A, B : Integer; C : Obj_Handle ); -- this version applies the same preconditions to all handlers. Procedure Intermediate (A, B : Integer; C : Obj_Handle; D : Handler) with Inline, pre =3D> A > 0 or B in positive'Range; Procedure Intermediate (A, B : Integer; C : Obj_Handle; D : Handler) is begin D( A, B, C ); end; To extend these with pre-/post-conditions we could add another type and ano= ther parameter to the handler. Type Condition is access function( P : Parameter ) return Boolean; Type Conditions is record Pre, Post : Condition; end record; -- This version applies the psudo-pre/post-conditions, as supplied. Procedure Intermediate (A, B : Integer; C : Obj_Handle; D : Handler; E : Co= nditions) with inline, pre =3D> (if condition'(E.Pre) /=3D Null then E.Pre), post =3D> (if condition'(E.Post) /=3D Null then E.Post); Procedure Intermediate (A, B : Integer; C : Obj_Handle; D : Handler; E : Co= nditions) is begin D( A, B, C ); end; Or something like it, no?