Summary: Uniform function call syntax (pseudo member)
                    enhancement suggestions
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from Tommi <> 2012-07-12 01:54:22 PDT ---
As I see it, the goal of uniform function call syntax, as 
described here, is to 
allow non-intrusively extending the functionality of a type. I 
think the current implementation falls short in accomplishing 
this goal on two accounts:

1) You can't non-intrusively add static member functions
2) You can't non-intrusively add constructors

So, I'm suggesting these two features to be added to the language:

1. Static members as free functions
    If function invocations like the following are encountered...

    A) Type.func(<ARGUMENTS>);
    B) Type.func; // it's a static @property function

    ...and those functions haven't been implemented as members,
    the function invocations get lowered into:

    A) func!Type(<ARGUMENTS>);
    B) func!Type;

    For example:
    enum Fruit {apple, orange}

    // CODE               // LOWERED CODE
    Fruit.letEmRot();     // .letEmRot!Fruit();
    if (Fruit.isEatable)  // if (.isEatable!Fruit)
      Fruit myfruit;
      myfruit.split(3);   // .split!Fruit(3); // only if it can't
                                              // be lowered into:
                                              // .split(myfruit, 3)

2. Class & struct constructors as free functions
    If a constructor call hasn't been implemented by Type...

    auto t = Type(<ARGUMENTS>);

    ...then it get's lowered into a free function call...

    auto t = .make!Type(<ARGUMENTS>);

    For example:
    enum Fruit {apple, orange}

    // CODE                 // LOWERED CODE
    auto f = Fruit("red");  // auto f = .make!Fruit("red");

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to