On Sunday, March 16, 2003, at 05:09 PM, David Storrs wrote:

==QUESTION
- Page 8 says "In some languages, all methods are multimethods."  I
believe that Java is one of these.  Is that right and what are some
others?  (This is really just curiousity.)
==/

Doesn't C++ work this way? Also I believe Pike allows overloading of methods by default.


==QUESTION
- Given the following code, what is called by $ride.current_speed()?

    class Vehicle {
      my $speed;
      method current_speed() { return $speed; }
      method set_speed($n) { $speed = $n; }
    }

    class Car {
      submethod current_speed() {
         print SUPER.current_speed();
         return SUPER.current_speed();
      }
    }

class A6 { }

    my $ride = new A6;            # Perl with German engineering???
    $ride.set_speed(60);          # Calls Vehicle.set_speed()
    print $ride.current_speed();  # Calls what?

Unless this is more complicated than I think, Car's current_speed() is called.


That said, a minor nitpick is that you'd want something more like

class Vehicle { ... }
class Car is Vehicle { ... }
class A6 is Car { ... }



Reply via email to