www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2785] New: Interfaces should be able to require non-member functions

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2785

           Summary: Interfaces should be able to require non-member
                    functions
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


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.


-- 
Apr 02 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2785






I agree with the suggestion, but why not 'static'?


-- 
Apr 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2785







 I agree with the suggestion, but why not 'static'?
 
static still implies member function. --
Apr 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2785






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?  ;)


-- 
Apr 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2785







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)'?


-- 
Apr 03 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2785


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





14:29:08 PDT ---
I'm dropping this because introspection seems to be a better path to achieving
such requirements.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 27 2009