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: 103376,1e36228aae0595da,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!news.motzarella.org!motzarella.org!not-for-mail From: =?UTF-8?B?UGF3ZcWCICdOaXZlcnRpdXMnIFDFgmF6aWXFhHNraQ==?= Newsgroups: comp.lang.ada Subject: Access to function returning class-wide type Date: Thu, 21 Aug 2008 12:13:10 +0200 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit X-Trace: feeder.motzarella.org U2FsdGVkX19NAfMqbEtBcRMxtS7QsmQNmZwbQTGC8F56k2eYQgMwxKMR6cJjRHSgaJ2jBItzvv+dKnAkTM0tpH6zr+N1QIXf0dxVFrnBAu7JtTs7bhjssv0ZCrEoszRu7G9YHK2+jbkzKktH1fjrHQ== X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Thu, 21 Aug 2008 10:13:11 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1/Ed+kZZhOd9ULod+o0rxU4zfScAyrZSlTDi2p6fShP3w== Cancel-Lock: sha1:2dn2Y6sCCiwJRYWS5cYVZBl525s= User-Agent: KNode/0.10.9 Xref: g2news1.google.com comp.lang.ada:1718 Date: 2008-08-21T12:13:10+02:00 List-Id: Hello all. I'm new here, but I'll try to stick on. Let me start with a tricky problem: Consider following code: ---------------------------------------- package A is type Abstracted is abstract tagged null record; function Proc (N : Natural) return Abstracted is abstract; type The_Access_Type is access function (N : Natural) return Abstracted'Class; end A; -- package A body ommited; with A; package B is type Derived is new A.Abstracted with null record; function Proc (N : Natural) return Derived; Failing_Object : A.The_Access_Type := B.Proc'Access; -- will not compile, error: 'expected type The_Access_Type / found type access function Proc defined at ...' function Proc_Wrapper (N : Natural) return Abstracted'Class; Working_Object : A.The_Access_Type := B.Proc_Wrapper'Access; -- compiler doesn't complain end B; package B body is function Proc_Wrapper (N : Natural) return Abstracted'Class is begin return Abstracted'Class'(Proc (N)); end Proc; -- function Proc body ommited end B; ---------------------------------------- What I need is a access type to 'constructor' of an derivate of abstract object. As I presented, there is a workaround, but that's not the 'right' way to do it. I really want to do it without some tricky wrapping. How do I define The_Access_Type to do what I want? Thanks in advance. -- Paweł Płazieński aka Nivertius "In the end, there will be Ada, XML and gzip"