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 Path: border2.nntp.dca3.giganews.com!backlog4.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!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Your wish list for Ada 202X Date: Wed, 23 Apr 2014 18:27:42 +0200 Organization: cbb software GmbH Message-ID: References: <7f1c01c5-3563-4b94-9831-152dbbf2ecdc@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: AuYlnUSfTZrfhAkRjyySpQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 2180 Xref: number.nntp.dca.giganews.com comp.lang.ada:186030 Date: 2014-04-23T18:27:42+02:00 List-Id: On Wed, 23 Apr 2014 17:46:04 +0200, J-P. Rosen wrote: > Le 23/04/2014 16:38, Dmitry A. Kazakov a écrit : >>> And what is the benefit over writing: >>> > Put_Line (F_T2_Image (V2)); >>> > ? >> generic >> type T is private; >> package Foo is ... >> >> package body Foo is >> procedure Bar (X : T) is >> begin >> ... X'Img ... >> >> That is the only use case for an attribute, in absence of primitive >> operations of course. > > But that would require every type to have a 'Img. Yes, you said you > wanted that, but there are clearly types where no sensible image could > be provided. No, I didn't want that. Instead I would do two things: 1. Classes for all types; 2. An interface named Printable (or whatever else name) with the primitive operation Image. Now, if a type is supposed to have Image, it must implement the interface. All scalar types will. If a record type need to have Image, you inherit to Printable. If Image is needed in a generic the formal type inherits to Printable. That's it. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de