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: border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!ottix-news.ottix.net!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Suggestion: Allow functions returning abstract types in certain situations Date: Sat, 24 May 2014 14:39:12 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <06f66a19-00f1-405f-a517-05d18a021b65@googlegroups.com> <8zl191j3jpi3.12xzqioq4t4hy.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1400956749 21062 192.74.137.71 (24 May 2014 18:39:09 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 24 May 2014 18:39:09 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:wMCnpB8AY3Mzny31sQV/OG26EuI= X-Original-Bytes: 2043 Xref: number.nntp.dca.giganews.com comp.lang.ada:186601 Date: 2014-05-24T14:39:12-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Wed, 21 May 2014 19:19:21 -0400, Robert A Duff wrote: >> Not sure what you mean about "redispatch". You can't [re]dispatch >> without converting to class-wide. > > Actually you can: > > 1. The Rosen's trick. You put a class-wide access discriminant into the > abstract type and dispatch on it. > > 2. Consider: > > type T is tagged ...; -- Non-abstract > type S is abstract new T with ...; -- Abstract > > You convert to T, then that to T'Class and then dispatch on that. Never > needed S'Class to make it crash. Good points. I still think it could work, given certain restrictions. I should have said, "You can't [re]dispatch without obtaining a class-wide view." That's what would need to be prevented. > Morale. Type semantics must be respected. ? - Bob