Little demo of allowing basic types to implement interfaces.

Rory McGuire rjmcguire at
Wed Sep 4 03:33:15 PDT 2013

I have a basic solution but it can't handle basic types LOL! you have to
typedef them so that moduleName!T works.

and then the functions  have to be declared in the same module as the type.
Or alternatively you have to specify the module to use e.g.
Implements!(T,MyInterface, "mymodule").

I had to hard code the module name because dmd segfaults if you use
__MODULE__ in the contraint. Both references to asdf should be changed to
the module you are using.

On Wed, Sep 4, 2013 at 11:48 AM, Rory McGuire <rjmcguire at> wrote:

> Thanks, the exact example is exceptions. Was working really late the day
> that it wasn't working :D my bad. The following is what I was after, which
> I really thought I had tried.
> class BaseException : Exception {
>     this(string s="", string file = __FILE__, int line = __LINE__) {
>         super(s, file, line);
>     }
> }
> On Wed, Sep 4, 2013 at 11:33 AM, Dicebot <public at> wrote:
>> On Wednesday, 4 September 2013 at 09:23:44 UTC, Rory McGuire wrote:
>>> thanks, yes, I just found that in TDPL. knew it was templates but forgot
>>> about template mixins.
>>> Do you know how to get a default parameter like __MODULE__ or __LINE__ to
>>> be used from the calling site?
>>> I've tried but I think my DMD is broken because it doesn't even work
>>> when I
>>> subclass Exception().
>> Special tokens like __LINE__ in default parameters are evaluated at the
>> call site:
>> It does not help though, because you don't need __MODULE__ of the call
>> site, you need list of modules it has imported in exact call scope.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d-announce mailing list