FYI: The support for variant function (aka polymorphic overloading)
has now reached a semi-useable state in Pike 7.9:

| Pike v7.9 release 5 running Hilfe v3.5 (Incremental Pike Frontend)
| > class foo {
| >>  variant int bar(int a) { return a*2; }
| >>  variant string bar(string s) { return "FOO" + s + "FOO"; }
| >>  variant string bar() { return "FOO"; }
| >> }
| > typeof(foo()->bar);
| (1) Result: function( : string) | function(int : int) | function(string : 
string)
| > foo()->bar(17);
| (2) Result: 34
| > foo()->bar("BAR");
| (3) Result: "FOOBARFOO"
| > foo()->bar();
| (4) Result: "FOO"
| > foo()->bar(1.2);
| Compiler Error: 1: Bad argument 1 to bar.
| Compiler Error: 1: Expected: string | int.
| Compiler Error: 1: Got     : float.
| > foo()->bar((mixed)1.2);
| Invalid arguments to bar()!
| HilfeInput:1: HilfeInput()->foo()->bar(1.2)
| HilfeInput:1: HilfeInput()->___HilfeWrapper()

I would appreciate feedback especially regarding the expected
semantics for:

  * When the variants have different modifiers (protected, private, etc).

  * When there's a function without the variant keyword.

  * When the types for the variants aren't disjunct.

  * When overriding X from an inherit with a variant function.

    - A non-variant function.

    - A variant function with a new definition with the same type.

    - A variant function with a new definition with a different type.

  * Should the previous definition be accessible in any of the above
    cases, or only if there's an explicit trampoline?

  * Multiple inherits of variant functions.

    - With the same types.

    - With different types.

I've probably forgotten or not thought of some cases, please mention
the expected semantics for these as well.

        /grubba
  • FYI... Henrik Grubbstr�m (Lysator) @ Pike (-) developers forum
    • ... Arne Goedeke
      • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
        • ... Martin Bähr
    • ... Martin Bähr

Reply via email to