comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: 'withing' problem
Date: Wed, 07 Nov 2001 00:38:38 GMT
Date: 2001-11-07T00:38:38+00:00	[thread overview]
Message-ID: <io%F7.3554$Mt6.1856123@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 3be800d3$0$230$ed9e5944@reading.news.pipex.net

> Using the Ada-like notation of your example, 'toString' dispatches on the
> type of parameter x. In fact, the call is written 'expr.toString' as in
> other OO languages, so (unlike the case in Ada) it is obvious what the call
> dispatches on.
  Actually, it's not the case that
   function toString(x : anything) return seq;
shows an ambiguity about dispatching in Ada, since it's not (legal) Ada.

> We define a base class 'anything' from which all other classes derive (like
> Java's 'Object'). This base class has an abstract method 'toString' (just
> like Java) having a return type 'seq of char' (where 'seq' is a templated
> type representing a sequence). But 'seq' is, like all other classes, derived
> from 'anything'.
   Does "seq" have any children?  Does it inherit things from "anything"?
Given "x : seq;", what does "toString(x);" produce?  More generally,
why is "seq" derived from "anything" rather than just standing on its own?

> So the declaration of 'anything' needs to see a forward declaration of 'seq'.
Actually it's the declaration of "toString" that needs a preceding declaration
of "seq".

How about

  type anything is tagged null record;
  type seq is new anything with record
    ...
  end record;
  function toString(x:anything'class) return seq;

and then use overloading to create

  function toString(x : first_child_of_anything'class) return seq;
  function toString(x : second_child_of_anything'class) return seq;
  function toString(x : first_of_first_child_of_anything'class) return seq;
etc.
Then calls look like
  a_seq := first_child.toString(x);
  a_seq := second_child.toString(y);
  a_seq := first_of_first_child.toString(x);



  reply	other threads:[~2001-11-07  0:38 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-02 10:24 'withing' problem David Crocker
2001-11-02 10:58 ` David C. Hoos, Sr.
2001-11-02 21:32   ` Florian Weimer
2001-11-02 14:49 ` Robert Dewar
2001-11-05  9:49   ` David Crocker
2001-11-02 15:06 ` Wes Groleau
2001-11-02 15:21 ` Ted Dennison
2001-11-02 17:19   ` Ed Falis
2001-11-02 18:17     ` Preben Randhol
2001-11-02 19:15       ` Ed Falis
2001-11-03  2:52       ` DuckE
2001-11-03  9:50         ` Preben Randhol
2001-11-03  8:25   ` Simon Wright
2001-11-03 17:27     ` Richard Riehle
2001-11-04 10:23       ` Simon Wright
2001-11-08 10:58         ` Preben Randhol
2001-11-08 15:24           ` Peter Hend�n
2001-11-10 17:57           ` Simon Wright
2001-11-05  9:48       ` David Crocker
2001-11-05 20:36         ` Ted Dennison
2001-11-06 15:56           ` David Crocker
2001-11-07 15:06             ` Ted Dennison
2001-11-07 16:49               ` Darren New
2001-11-09 20:28         ` Matthew Heaney
2001-11-10 13:55           ` Preben Randhol
2001-11-12 15:10             ` Matthew Heaney
2001-11-10 18:12           ` Simon Wright
2001-11-12 15:13             ` Matthew Heaney
2001-11-13  7:01               ` Simon Wright
2001-11-14 16:10                 ` Matthew Heaney
2001-11-15 20:21                   ` Simon Wright
2001-11-15 21:07                     ` Matthew Heaney
2001-11-16 14:37                     ` Stephen Leake
2001-11-17 22:29                     ` Richard Riehle
2001-11-18 14:53                       ` Simon Wright
2001-11-19  5:51                         ` Simon Wright
2001-11-19 15:23                         ` Matthew Heaney
2001-11-19 17:19                           ` 'withing' problem [code generation] Mark Johnson
2001-11-19 20:58                             ` Stephen Leake
2001-11-19 21:20                               ` Matthew Heaney
2001-11-21  6:20                                 ` Simon Wright
2001-11-20  0:50                               ` Mark Biggar
2001-11-21  6:21                                 ` Simon Wright
2001-11-20 14:42                               ` Mark Johnson
2001-11-20 16:34                                 ` David Crocker
2001-11-20 18:34                                   ` Richard Pinkall-Pollei
2001-11-20 18:43                                   ` Matthew Heaney
2001-11-20 20:37                                     ` Mark Lundquist
2001-11-22 11:49                                     ` David Crocker
2001-11-20 20:35                                   ` Mark Lundquist
2001-11-22 11:42                                     ` David Crocker
2001-11-19 19:30                           ` 'withing' problem Preben Randhol
2001-11-03  8:26 ` Simon Wright
2001-11-03  8:38 ` Simon Wright
2001-11-05  9:54   ` David Crocker
2001-11-05 18:04     ` tmoran
2001-11-06 15:29       ` David Crocker
2001-11-07  0:38         ` tmoran [this message]
2001-11-07 10:11           ` David Crocker
2001-11-07 18:59             ` tmoran
2001-11-08 11:38               ` David Crocker
2001-11-10 18:03                 ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox