On Tuesday, 25 February 2014 at 19:37:04 UTC, Walter Bright wrote:
This is a most interesting idea. Please pursue.

I talked about it a little while ago in a thread on the forum (it was also my dconf submission but since I don't really want to travel anyway that surely won't happen).

http://forum.dlang.org/thread/majnjuhxdefjuqjlp...@forum.dlang.org

The basic thing is to change object.d's RTInfo template to import an empty module and mixin a name. Projects would be able to override it by just writing their own module with the same name instead. Then, the compiler goes looking and prefers the user's one from the one in druntime.

It's doable right now, but we could improve it by adding an rtinfo like thing for modules too, or maybe even functions.

Some related bugzillas to rtinfo:

add it for modules too:
https://d.puremagic.com/issues/show_bug.cgi?id=10023

some bugs:
https://d.puremagic.com/issues/show_bug.cgi?id=10442
https://d.puremagic.com/issues/show_bug.cgi?id=10786

add it for built-in types too (not strictly necessary here)
https://d.puremagic.com/issues/show_bug.cgi?id=11670


I would *love* to have access to the call stack and local variables too, then we can do custom things a la @safe in the lib too. But I think we can go one step at a time, checking user structs and classes is possible today and gives some good possibilities.


Among the things I've done in my proof of concept:

rtinfo.d:
module core.rtinfo;
mixin template ProjectRtInfo(T) {
   import lint.virtuals;
   static assert(virtualCheck!T);
}

test.d:
import lint.virtuals;

class Foo {
        void foo() {}
}


$ dmd test53 virtuals.d  rtinfo.d
Warning Foo.foo is virtual

test.d:
import lint.virtuals;

class Foo {
        @virtual void foo() {}
}
$ dmd test53 virtuals.d  rtinfo.d
# works!

Reply via email to