Bug 2785 – Interfaces should be able to require non-member functions
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-04-02T12:56:00Z
Last change time
2015-06-09T05:15:22Z
Assigned to
nobody
Creator
andrei
Comments
Comment #0 by andrei — 2009-04-02T12:56:56Z
This should work:
interface Foo
{
extern void bar(int, Foo, double);
}
meaning that a non-member function bar should exist that accepts an int, the implementor of Foo, and a double.
Comment #1 by jarrett.billingsley — 2009-04-02T13:18:29Z
I agree with the suggestion, but why not 'static'?
Comment #2 by andrei — 2009-04-02T13:31:03Z
(In reply to comment #1)
> I agree with the suggestion, but why not 'static'?
>
static still implies member function.
Comment #3 by jarrett.billingsley — 2009-04-02T13:49:38Z
OK, then maybe I'm not understanding what you're proposing. When I see "member function" I think "a function meant to be called on an instance of a class" as opposed to on the class itself. (I'd love to see 'abstract static' methods, which is what I thought this was proposing.)
Are you saying that when a class implements Foo, there must be a function void bar(int, Foo, double) accessible from that scope? What horrid things are you planning on doing with that? ;)
Comment #4 by sandford — 2009-04-03T23:54:18Z
(In reply to comment #0)
I like the concept of extern functions in this concept, though it does rise questions of what scopes/modules are used for match searching. However, the use of Foo to mean the class name seems like the wrong keyword. What if I truly wanted a function that took a Foo? Also, it makes these function definitions behave differently than definitions outside the interface. Perhaps 'super' or 'typeof(this)'?
Comment #5 by andrei — 2009-08-27T14:29:08Z
I'm dropping this because introspection seems to be a better path to achieving such requirements.