Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Jacob Carlborg
On 2013-09-04 13:57, Rory McGuire wrote: Thanks! a module declaration gets around that one. http://dpaste.dzfl.pl/cff0ca5a line 21 I think this should already be fixed in git HEAD. -- /Jacob Carlborg

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Rory McGuire
Thanks! a module declaration gets around that one. http://dpaste.dzfl.pl/cff0ca5a line 21 On Wed, Sep 4, 2013 at 1:18 PM, Jacob Carlborg wrote: > On 2013-09-04 13:01, Rory McGuire wrote: > >> yip, :) can't think of a reason except it was interesting. wish dmd >> didn't segfault when I used __MO

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Jacob Carlborg
On 2013-09-04 13:01, Rory McGuire wrote: yip, :) can't think of a reason except it was interesting. wish dmd didn't segfault when I used __MODULE__. on the plus side the requirement for a non basic type is the same requirement that #golang has on its interfaces. Do you have a module declaratio

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Rory McGuire
yip, :) can't think of a reason except it was interesting. wish dmd didn't segfault when I used __MODULE__. on the plus side the requirement for a non basic type is the same requirement that #golang has on its interfaces. On Wed, Sep 4, 2013 at 12:48 PM, Dicebot wrote: > On Wednesday, 4 Sept

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Dicebot
On Wednesday, 4 September 2013 at 10:33:26 UTC, Rory McGuire wrote: I have a basic solution but it can't handle basic types LOL! you have to typedef them so that moduleName!T works. Of course it can't, built-in types don't have any owning module, those are not symbols. Why would you want to c

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Rory McGuire
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"). http://

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Rory McGuire
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,

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Dicebot
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 m

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Rory McGuire
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().

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Dicebot
On Wednesday, 4 September 2013 at 08:56:10 UTC, Rory McGuire wrote: A template should get evaluated in the calling context. No, in D templates use declaration scope (unless they are template mixins).

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Dicebot
On Wednesday, 4 September 2013 at 08:44:45 UTC, Rory McGuire wrote: yes, it does seem to break if the Implements template func is in a different module to the free standing func. hmph, how to get around that. I don't think it is possible. You can possibly have several modules with free stand

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Rory McGuire
So the general idea would be to add: mixin("import "~ mod ~";"); into the check() inner function but mod needs to come from somewhere. I haven't been able to make it as a template yet. A template should get evaluated in the calling context. On Wed, Sep 4, 2013 at 10:44 AM, Rory McGuire wrote:

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Rory McGuire
yes, it does seem to break if the Implements template func is in a different module to the free standing func. hmph, how to get around that. On Wed, Sep 4, 2013 at 9:04 AM, Tobias Pankrath wrote: > On Wednesday, 4 September 2013 at 00:56:55 UTC, Rory McGuire wrote: > >> I was wondering if its

Re: Little demo of allowing basic types to implement interfaces.

2013-09-04 Thread Tobias Pankrath
On Wednesday, 4 September 2013 at 00:56:55 UTC, Rory McGuire wrote: I was wondering if its possible to do interfaces the way #golang does it but in #dlang. Here is my first try: https://gist.github.com/rjmcguire/6431542. Any help on making this smaller would be awesome. Cheers, R Will this

Re: Little demo of allowing basic types to implement interfaces.

2013-09-03 Thread Rory McGuire
On Wednesday, 4 September 2013 at 06:27:54 UTC, Rory McGuire wrote: On Wednesday, 4 September 2013 at 06:26:08 UTC, Rory McGuire wrote: On Wednesday, 4 September 2013 at 00:56:55 UTC, Rory McGuire wrote: I was wondering if its possible to do interfaces the way #golang does it but in #dlang. H

Re: Little demo of allowing basic types to implement interfaces.

2013-09-03 Thread Rory McGuire
On Wednesday, 4 September 2013 at 06:26:08 UTC, Rory McGuire wrote: On Wednesday, 4 September 2013 at 00:56:55 UTC, Rory McGuire wrote: I was wondering if its possible to do interfaces the way #golang does it but in #dlang. Here is my first try: https://gist.github.com/rjmcguire/6431542. Any

Re: Little demo of allowing basic types to implement interfaces.

2013-09-03 Thread Rory McGuire
On Wednesday, 4 September 2013 at 00:56:55 UTC, Rory McGuire wrote: I was wondering if its possible to do interfaces the way #golang does it but in #dlang. Here is my first try: https://gist.github.com/rjmcguire/6431542. Any help on making this smaller would be awesome. Cheers, R Here is an