Re: Gerry Quinn: Legend in his own mind ( Re: Dijkstra gets it wrong [was: Re: D gets it right] )

From: Joe \ (joe_at_bftsi0.UUCP)
Date: 02/24/04


Date: Tue, 24 Feb 2004 14:36:41 -0800


"Gerry Quinn" <gerryq@indigo.ie> wrote in message <news:60Q_b.4544$rb.62062@news.indigo.ie>...

> In article <1077654012.548758@news-1.nethere.net>, "Joe \"Nuke Me Xemu\" Foster" <jlf%40znet%2ecom> wrote:
> >"Gerry Quinn" <gerryq@indigo.ie> wrote in message
> > <news:20N_b.4517$rb.61930@news.indigo.ie>...
> >
> >> If they don't have extra non-static data, you can convert them by
> >> casting. If they do, the global functions concept wouldn't work anyway.
> >
> >Nonsense. A (probably new) language could combine overloading
> >with dynamic polymorphism. Perhaps some unholy *** child
> >of RTTI and Koenig lookup?
>
> It's not nonsense, and we were talking about C++, not any other
> language.

You might be, after having mistaken both this newsgroup and
comp.games.development.programming.misc for comp.lang.c++.

> If global functions are capable of replacing member functions, they
> cannot [pace bizarre systems in which a subsidiary class is created to
> store data externally for each instance of a class]

Unnecessary. Programmers do the same thing all too often manually.
Pseudocode:

sub speak(x as object)
  if typeof x is animal then
    ' check for subtypes of animal
    if typeof x is vertebrate then
      ' check for subtypes of vertebrate
      if typeof x is mammal then
        ' check for subtypes of mammal
        if typeof x is cat then
          speak_cat x
        elseif typeof x is dog then
          speak_dog x
        else
          speak_mammal x
        end if
      else
        speak_vertebrate x
      end if
    else
      speak_animal x
    end if
  else
    speak_object x
  end if
end if

This is the sort of thing a compiler (or VB add-in!) could generate
automagically.

> do anything that
> involves extra member data not in the original class. Therefore the
> original class can be cast to the derived class wherever it appears,
> since its data structure is the same. Therefore, the 'factory' problem
> still does not justify the nonsense about preferring global functions.

Will this still work if the factory function might return an instance
of some other class derived from X as well as or instead of an X and
only an X?

--
Joe Foster <mailto:jlfoster%40znet.com>  "Regged" again? <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!