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: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.N5M2DXr2fJIsm61cKlUWUQ.user.gioia.aioe.org!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: User defined implicit conversion Date: Wed, 30 Oct 2019 19:58:17 +0000 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: N5M2DXr2fJIsm61cKlUWUQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:x2Oa+DxpStYNnv1rPi+/Q+zuwIU= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:57391 Date: 2019-10-30T19:58:17+00:00 List-Id: Alain De Vos writes: > Casting from one type to another is a real pain. > Does the functionality "User defined implicit conversion" exists? > If not are there strategies, general rules, to limit conversion to a > minimum ? > > We don't want as concatination : > result := to_type_a (from_type_a (X) & from_type_a (Y)) ; > when you could have : > result := X & Y ; function "&" (L : Type_X, R : Type_Y) return Type_A; function "&" (L : Type_Y, R : Type_X) return Type_A; which means that the tiresome manipulation only has to happen in one place. Well, two places, unless you say function "&" (L : Type_Y, R : Type_X) return Type_A is (R & L);