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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada,comp.object Subject: Object oriented (question) Followup-To: comp.lang.ada Date: Fri, 20 Oct 2017 01:48:41 +0300 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: 8U0x309/ia0QUzusgm/krA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:48521 comp.object:1765 Date: 2017-10-20T01:48:41+03:00 List-Id: I am writing thick (object oriented) Ada2012 bindings of a C library. Right now I am finishing to implement bindings for: http://librdf.org/docs/api/redland-parser.html My bindings are in https://github.com/vporton/redland-bindings/blob/ada2012/ada/src/rdf-redland-parser.ads https://github.com/vporton/redland-bindings/blob/ada2012/ada/src/rdf-redland-parser.adb Particularly I defined Parser_Type tagged type to describe RDF parsers. We should be able to attach an URL filter (allowing/disallowing certain URLs to be downloaded). Should the URL filter be implemented simply as a primitive function (intended to be called with dynamic dispatch like virtual function in C++) which returns Boolean? Or should I create a special tagged type URI_Filter_Type and procedure like procedure Attach (Parser: Parser_Type; Filter: URI_Filter_Type'Class); ? The first is easier to implement. But it looks not elegant, maybe violating single responsibility principle (Parser_Type is responsible both for parsing and URI filtering). The second is harder to implement and harder to invoke (at least in simple situations), as it would require an additional variable Filter: URI_Filter_Type; every time when it is used with a Parser_Type object. But the second one is more flexible in principle. However, do I really need this flexibility? The implementation of Parser_Type would require just one overridable subprogram. So the argument that to properly overriding multiple subprograms multiple inheritance (which is missing in Ada) would be needed, looks like a void argument. So, please help me to choose. Note that the only reason to decide should be convenience of using of my library, not complexity to implement, as I can implement it in any case. -- Victor Porton - http://portonvictor.org