Re: is there any way for an object to make it self no longer usable

2014-07-19 Thread Frustrated via Digitalmars-d-learn
On Saturday, 19 July 2014 at 12:02:50 UTC, Sean Campbell wrote: is there any way for an object to make it self no longer usable? eg class someclass { string somevalue; bool someflag; int somelength; this (value,length,flag) { somevalue = value;

Implement Interface "dynamically"

2014-07-14 Thread Frustrated via Digitalmars-d-learn
Is there a way to take an interface and implement it generically? e.g., All functions are implemented either as throw and/or return defaults and properties are implemented as getter/setters. This is for mocking up so I a simple way to create a class based off only the interface. Essentially

Re: dustmite build

2014-07-07 Thread Frustrated via Digitalmars-d-learn
On Monday, 7 July 2014 at 17:50:35 UTC, Frustrated wrote: when I build dustmite using dmd or gdc with no options or -O3, it is 18M but in the dmd directory, dustmite is only 650k. I assume I'm statically linking the whole library while in the small one is using some dynamic link library?

dustmite build

2014-07-07 Thread Frustrated via Digitalmars-d-learn
when I build dustmite using dmd or gdc with no options or -O3, it is 18M but in the dmd directory, dustmite is only 650k. I assume I'm statically linking the whole library while in the small one is using some dynamic link library? Or is all that debug information or what?

Re: recursive definition error

2014-07-07 Thread Frustrated via Digitalmars-d-learn
On Monday, 7 July 2014 at 09:56:17 UTC, Marc Schütz wrote: On Monday, 7 July 2014 at 02:57:09 UTC, Frustrated wrote: So, I took all the code surrounding the error message(which was a lot of code) and stuck it into one .d file. No errors! Works as expected. So, WTF?!?! I guess now I have to

Re: recursive definition error

2014-07-06 Thread Frustrated via Digitalmars-d-learn
So, I took all the code surrounding the error message(which was a lot of code) and stuck it into one .d file. No errors! Works as expected. So, WTF?!?! I guess now I have to attempt to split the code across modules to see WTF is going on? Maybe this is a modules issue. I know some of the cod

Re: recursive definition error

2014-07-06 Thread Frustrated via Digitalmars-d-learn
On Friday, 4 July 2014 at 21:15:02 UTC, Frustrated wrote: On Friday, 4 July 2014 at 20:25:28 UTC, Frustrated wrote: On Friday, 4 July 2014 at 16:31:28 UTC, Stanislav Blinov wrote: On Friday, 4 July 2014 at 16:28:48 UTC, Frustrated wrote: On Friday, 4 July 2014 at 15:42:36 UTC, bearophile

Re: recursive definition error

2014-07-04 Thread Frustrated via Digitalmars-d-learn
On Friday, 4 July 2014 at 20:25:28 UTC, Frustrated wrote: On Friday, 4 July 2014 at 16:31:28 UTC, Stanislav Blinov wrote: On Friday, 4 July 2014 at 16:28:48 UTC, Frustrated wrote: On Friday, 4 July 2014 at 15:42:36 UTC, bearophile wrote: Frustrated: I'm not using 2.066 though... I

Re: recursive definition error

2014-07-04 Thread Frustrated via Digitalmars-d-learn
On Friday, 4 July 2014 at 16:31:28 UTC, Stanislav Blinov wrote: On Friday, 4 July 2014 at 16:28:48 UTC, Frustrated wrote: On Friday, 4 July 2014 at 15:42:36 UTC, bearophile wrote: Frustrated: I'm not using 2.066 though... I will revert back to the dmd version I was using when it w

Re: recursive definition error

2014-07-04 Thread Frustrated via Digitalmars-d-learn
On Friday, 4 July 2014 at 15:42:36 UTC, bearophile wrote: Frustrated: Since there is no recursion going on there, it shouldn't be a problem. Yes, sorry. In dmd 2.066 this too could work: alias Array(T) = std.container.Array!T; Bye, bearophile That just gives more errors. I'm

Re: recursive definition error

2014-07-04 Thread Frustrated via Digitalmars-d-learn
On Friday, 4 July 2014 at 15:37:52 UTC, Marc Schütz wrote: On Friday, 4 July 2014 at 15:07:00 UTC, Frustrated wrote: After upgrading to latest dmd, I get the follow error on the code template Array(T) { alias Array = std.container.Array!T; } Error: Array!(iDataBlock).Array recursive alias

Re: recursive definition error

2014-07-04 Thread Frustrated via Digitalmars-d-learn
On Friday, 4 July 2014 at 15:10:14 UTC, bearophile wrote: Frustrated: After upgrading to latest dmd, I get the follow error on the code template Array(T) { alias Array = std.container.Array!T; } Try to use a different name inside the template, like "Vector". Bye, bearophile

recursive definition error

2014-07-04 Thread Frustrated via Digitalmars-d-learn
After upgrading to latest dmd, I get the follow error on the code template Array(T) { alias Array = std.container.Array!T; } Error: Array!(iDataBlock).Array recursive alias declaration I don't see anything recursive about it... and the code worked before. Any ideas?

Re: Structs insted of classes for Performance

2014-04-20 Thread Frustrated via Digitalmars-d-learn
On Sunday, 20 April 2014 at 16:56:59 UTC, Ali Çehreli wrote: My understanding is not perfect. There may be compiler and CPU optimizations that I am not aware of. On 04/20/2014 08:03 AM, Frustrated wrote: > is the only argument really about performance when creating > structs vs cr

Structs insted of classes for Performance

2014-04-20 Thread Frustrated via Digitalmars-d-learn
I know the difference between a struct and a class but I remember seeing somewhere that structs are much faster than classes in D for some strange reason. I'm not worried too much about class allocation performance because I will try and use classes when they will not be created frequently an

Re: can I generate an enum from a typelist?

2014-04-08 Thread Frustrated
On Tuesday, 8 April 2014 at 08:31:16 UTC, Vlad Levenfeld wrote: Ok, starting to feel a bit sheepish at this point, that constructor was unnecessarily verbose: this (T) (T layer) { import std.string: toLower; mixin ("this."~toLower (T.stringof)~"= layer;"); this.type = ca

Re: Why defining alias and not auto when using a template?

2014-04-04 Thread Frustrated
On Friday, 4 April 2014 at 13:23:48 UTC, Bienlein wrote: Hello, I took some code snippet from some sample D code and modified it a bit: template TCopy(T, V) { private int i = 2; void copy(out T to, out V to2, T from) { to = from; to2 = from; writeln("i: ", i); } }

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread Frustrated
On Tuesday, 1 April 2014 at 19:52:47 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 15:00:17 -0400, Frustrated wrote: On Tuesday, 1 April 2014 at 12:20:06 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 03:31:41 -0400, Frustrated wrote: Basically in programming to interfaces I

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread Frustrated
On Tuesday, 1 April 2014 at 12:20:06 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 03:31:41 -0400, Frustrated wrote: Basically in programming to interfaces I need to decide to call a virtual method of an object if it exists else call a final method in the interface: interface A

How to dynamically call class virtual method dynamically

2014-04-01 Thread Frustrated
Basically in programming to interfaces I need to decide to call a virtual method of an object if it exists else call a final method in the interface: interface A { static final void foo() { ... } } class B : A { void bar() { ... } // optional } class C : B { void bar() { ... }

Re: Template magic exercise

2014-03-30 Thread Frustrated
On Sunday, 30 March 2014 at 12:42:16 UTC, Jack Applegame wrote: Target is to create a template for mapping member "array accessor" to member function. For example: class Foo { ... int elementsAccessor(size_t index) { ... } ... mixin MagicTemplateMixin!("elements", elementsAccessor);

Re: Compile time only delegates

2014-03-25 Thread Frustrated
On Tuesday, 25 March 2014 at 18:10:17 UTC, Meta wrote: On Tuesday, 25 March 2014 at 18:05:47 UTC, Frustrated wrote: Due to a previous issue I am trying to do the following mixin template A() { mixin((function () => "int x;")() ); } the problem is that the compiler will not l

Re: Compile time only delegates

2014-03-25 Thread Frustrated
On Tuesday, 25 March 2014 at 20:20:29 UTC, Frustrated wrote: On Tuesday, 25 March 2014 at 18:10:17 UTC, Meta wrote: On Tuesday, 25 March 2014 at 18:05:47 UTC, Frustrated wrote: Due to a previous issue I am trying to do the following mixin template A() { mixin((function () => &qu

Compile time only delegates

2014-03-25 Thread Frustrated
Due to a previous issue I am trying to do the following mixin template A() { mixin((function () => "int x;")() ); } the problem is that the compiler will not let me use the delegate because it has no this context. Of course the whole point here is that the delegate will never be used at ru

Re: TDPL question: "objects may not embed internal pointers", classes too?

2014-03-16 Thread Frustrated
On Sunday, 16 March 2014 at 18:41:51 UTC, Adam D. Ruppe wrote: On page 249 of TDPL (Andrei's book), in a section on structs and postblits, it says "D objects must be relocatable" and other similar statements while banning internal pointers. I knew this applies to structs and the context makes

Re: Template mixins - why only declarations

2014-03-06 Thread Frustrated
On Thursday, 6 March 2014 at 17:27:35 UTC, Steve Teale wrote: Pretty much what the subject says. Why can't template mixins include statements ans so on? Is it just too hard, or is it just too much like C macros? Steve template mixins mix in directly into the code as if you typed them. If th

Re: enum return type

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 23:36:34 UTC, Adam D. Ruppe wrote: On Wednesday, 5 March 2014 at 23:17:45 UTC, Frustrated wrote: is it a purely compile time construct? I think it is the same as auto return functions. Both auto and enum in this context are storage classes. In the compiler, it

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 23:33:25 UTC, Frustrated wrote: Maybe the problem isn't what I thought it was. I created a test case that works: import std.stdio, std.cstream; mixin template C() { alias A = typeof(this); mixin(B!(A)); } template B(T) { pragma(m

Re: enum return type

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 23:20:08 UTC, bearophile wrote: Frustrated: how does an enum return type work? enum foo(string s) { return s; } As far as I know that's not valid D (but D is extremely tolerating). Bye, bearophile Well, it works... not sure exactly what it's doing though.

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
Maybe the problem isn't what I thought it was. I created a test case that works: import std.stdio, std.cstream; mixin template C() { alias A = typeof(this); mixin(B!(A)); } template B(T) { pragma(msg, T); enum B() { return "string foo() { return `<"~T.stringof~">`; }";

enum return type

2014-03-05 Thread Frustrated
how does an enum return type work? enum foo(string s) { return s; } is it a purely compile time construct? That is, we can guarantee that foo, as a function, won't exist at runtime? e.g., it is a true ctfe instead of a function that can be executed at compile time or runtime?

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 23:04:06 UTC, Ali Çehreli wrote: On 03/05/2014 02:37 PM, Frustrated wrote: >> import std.typetuple; >> >> template fooImpl(T...) >> { >> static assert(is (T[0] == S));// <-- COOL! >> static assert(is (T[1]

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 22:35:46 UTC, Ali Çehreli wrote: On 03/05/2014 01:30 PM, Frustrated wrote: I am trying to remove the unnecessary passing of the type of class to a template but can't seem to get it to work: see The code is the mixin(AbstractToInterface!(Windo

Strange Mixin issue

2014-03-05 Thread Frustrated
I am trying to remove the unnecessary passing of the type of class to a template but can't seem to get it to work: see The code is the mixin(AbstractToInterface!(WindowsGui, iButton, WindowsButton, iBorder, WindowsBorder)); which I want to not have to specify WindowsGui. I've t

Re: Nobody understands templates?

2014-03-03 Thread Frustrated
On Monday, 3 March 2014 at 18:46:24 UTC, Chris wrote: On Monday, 3 March 2014 at 18:03:12 UTC, Frustrated wrote: On Sunday, 2 March 2014 at 11:47:39 UTC, Steve Teale wrote: On Sunday, 2 March 2014 at 10:05:05 UTC, Dicebot wrote: There is nothing wrong about not using templates. Almost any

Re: Nobody understands templates?

2014-03-03 Thread Frustrated
On Sunday, 2 March 2014 at 11:47:39 UTC, Steve Teale wrote: On Sunday, 2 March 2014 at 10:05:05 UTC, Dicebot wrote: There is nothing wrong about not using templates. Almost any compile-time design can be moved to run-time and expressed in more common OOP form. And using tool you have mastery

Re: Nobody understands templates?

2014-02-28 Thread Frustrated
On Friday, 28 February 2014 at 18:42:57 UTC, Steve Teale wrote: All the D aficionados seem to wet their pants over meta-programming, but I struggle to find a place to use it. IIRC, I used it in a couple of places when I was trying to write library stuff for MySQL, but in my current project, I us

Runtime dependency checking

2014-02-25 Thread Frustrated
http://dpaste.dzfl.pl/80c6225ed090 The code above demonstrates run-time contracts using interface based programming. It provides two co-benfits: Simplified class implementation(you do not have to use interfaces for types which then requires casting that type for orthogonal behavior) and run-

Re: Programming to Interfaces simplification

2014-02-24 Thread Frustrated
Fixed code with all combination examples: (again, only WindowsButton works with WindowsGui and same for LinuxGui... but the classes don't use iButton like they should!!! Oh, they break the contract!! End of the world!) http://dpaste.dzfl.pl/02ee45225303 Output: Trying WindowsButton with Window

Re: Programming to Interfaces simplification

2014-02-24 Thread Frustrated
On Monday, 24 February 2014 at 18:59:32 UTC, Steven Schveighoffer wrote: On Mon, 24 Feb 2014 11:36:50 -0500, Frustrated wrote: http://dpaste.dzfl.pl/c25655e2dfe9 The code above simplifies using interfaces as the programming object. It allows one to program the derived classes as if they

Programming to Interfaces simplification

2014-02-24 Thread Frustrated
http://dpaste.dzfl.pl/c25655e2dfe9 The code above simplifies using interfaces as the programming object. It allows one to program the derived classes as if they were not part of an abstraction by mapping the abstracted virtual methods to concrete methods. e.g., class WindowsGui : iGui {

Re: Cannot implicitly convert derived type

2014-02-23 Thread Frustrated
On Sunday, 23 February 2014 at 23:14:24 UTC, Jesse Phillips wrote: On Sunday, 23 February 2014 at 21:06:03 UTC, Frustrated wrote: Why does your WindowsGui violate the iGui contract? It doesn't. It simply that one can't specify dependencies in D if (iGui is WindowsGui) then

Re: Cannot implicitly convert derived type

2014-02-23 Thread Frustrated
On Sunday, 23 February 2014 at 20:41:30 UTC, Jesse Phillips wrote: On Saturday, 22 February 2014 at 20:17:37 UTC, Frustrated wrote: I do this: @property WindowsButton button(WindowsButton b) { } The compiler turns this into @property WindowsButton button(iButton _b) { if (is(_b

loop over all parameters of all overloads of all members

2014-02-23 Thread Frustrated
The following code craps out on the inner for each foreach (am; __traits(derivedMembers, B)) foreach (m; [__traits(getOverloads, B, am)]) { } So how can I loop over all the parameters of all the overloads of

Re: Cannot implicitly convert derived type

2014-02-23 Thread Frustrated
On Sunday, 23 February 2014 at 01:37:08 UTC, Steven Schveighoffer wrote: On Sat, 22 Feb 2014 15:17:37 -0500, Frustrated wrote: It is legal exactly because I will always guarantee that the proper button will be used. Static typing says it's not legal. D does not do dynamic type che

Re: Cannot implicitly convert derived type

2014-02-22 Thread Frustrated
On Saturday, 22 February 2014 at 05:20:25 UTC, Eric Suen wrote: Generic? I don't see how this would help. I'd have to specify every concrete type in the creation of the object which might be significant. I can't use a generic virtual method so that doesn't help either. It would be nice to hav

Re: Cannot implicitly convert derived type

2014-02-22 Thread Frustrated
On Saturday, 22 February 2014 at 01:03:22 UTC, Steven Schveighoffer wrote: On Fri, 21 Feb 2014 17:54:06 -0500, Frustrated wrote: interface iGui { @property iButton button(ref iButton button); } class WindowsGui : iGui { WindowsButton _button; @property WindowsButton

Re: Cannot implicitly convert derived type

2014-02-21 Thread Frustrated
On Friday, 21 February 2014 at 23:19:19 UTC, Ali Çehreli wrote: On 02/21/2014 02:54 PM, Frustrated wrote: interface iGui { @property iButton button(ref iButton button); } class WindowsGui : iGui { WindowsButton _button; @property WindowsButton button(ref WindowsButton button

Cannot implicitly convert derived type

2014-02-21 Thread Frustrated
interface iGui { @property iButton button(ref iButton button); } class WindowsGui : iGui { WindowsButton _button; @property WindowsButton button(ref WindowsButton button) //@property iButton button(ref iButton button) { _button = button;

Re: Container templates

2014-02-20 Thread Frustrated
On Wednesday, 19 February 2014 at 21:50:43 UTC, Meta wrote: On Wednesday, 19 February 2014 at 19:44:12 UTC, Meta wrote: On Wednesday, 19 February 2014 at 19:10:44 UTC, Frustrated wrote: Are there container templates that one can mixin to classes that give them container behavior? e.g

Re: Container templates

2014-02-19 Thread Frustrated
On Wednesday, 19 February 2014 at 19:44:12 UTC, Meta wrote: On Wednesday, 19 February 2014 at 19:10:44 UTC, Frustrated wrote: Are there container templates that one can mixin to classes that give them container behavior? e.g., instead of class A { Array!int x; } I want class A

Container templates

2014-02-19 Thread Frustrated
Are there container templates that one can mixin to classes that give them container behavior? e.g., instead of class A { Array!int x; } I want class A { mixin Array!int; } so that I can do something like a.Add(3) instead of a.x.Add(3). In fact, I do want the first case because I w

Re: Circular Buffer

2014-02-13 Thread Frustrated
On Monday, 10 February 2014 at 10:41:06 UTC, Russel Winder wrote: On Mon, 2014-02-10 at 09:16 +, Gary Willoughby wrote: On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap wrote: > (disclaimer: I'm new around here) > Is it possible to cycle backwards? If not, what's the best > app

Re: std.random.uniform for enums

2014-02-12 Thread Frustrated
On Thursday, 13 February 2014 at 02:14:02 UTC, Jakob Ovrum wrote: On Thursday, 13 February 2014 at 02:02:38 UTC, Anton wrote: I'm confused about how to use random.uniform to select a member of an enum. Say I have an enum like enum Animals { cat = 0, dog = 1, chimpanzee =

Re: Templated static opCall in non-templated struct

2014-02-11 Thread Frustrated
On Tuesday, 11 February 2014 at 00:00:06 UTC, Matthew Dudley wrote: Here's the gist of what I'm trying to do: struct Foo { public: int i; int j; static opCall(int i)(int j, int k) { return Foo(i+j,i+k); } } void main() { auto bob

Re: How to call opCall as template?

2014-01-31 Thread Frustrated
Are you always so aggressive? :) Not always ;) Just when I feel like it

Re: mixin template

2014-01-31 Thread Frustrated
On Friday, 31 January 2014 at 06:26:16 UTC, Dan Killebrew wrote: On Friday, 31 January 2014 at 06:24:27 UTC, Dan Killebrew wrote: mixin template Foo(alias a){ alias Foo=a; } pragma(msg, Foo!2); // error template Bar(alias a){ alias Bar=a; } pragma(msg, Bar!2); // ok As far as I can tell, 'mix

Re: std.typecons.Rebindable

2014-01-31 Thread Frustrated
On Friday, 31 January 2014 at 08:40:30 UTC, Jack Applegame wrote: Why doesn't Rebindable allow associative arrays? import std.typecons; Rebindable!(immutable string[]) data1; // ok Rebindable!(immutable string[string]) data2; // error an associative array doesn't pass the isArray test

Re: How to call opCall as template?

2014-01-31 Thread Frustrated
On Friday, 31 January 2014 at 10:31:52 UTC, Namespace wrote: So, if your notation was implemented, it would no longer be easy to know. The compiler would have to be context sensitive, which is more complex and not perfect. I doubt Walter would go for that so you'll never be able to use an expl

Re: How to call opCall as template?

2014-01-31 Thread Frustrated
On Friday, 31 January 2014 at 00:29:20 UTC, Namespace wrote: On Thursday, 30 January 2014 at 22:34:52 UTC, Frustrated wrote: On Thursday, 30 January 2014 at 21:33:09 UTC, Namespace wrote: I think for your example, the first case works fine using deduction. Sure but this is not always

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 21:42:39 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 16:23:55 -0500, Frustrated wrote: Again, you have to get off of what has been defined. You have the mentality exactly the same as those that thought the earth was flat, imaginary numbers were

Re: How to call opCall as template?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 21:33:09 UTC, Namespace wrote: I think for your example, the first case works fine using deduction. Sure but this is not always possible. ;) It seems that the problem occurs also with opIndex and so probably with all op* methods. See: http://forum.dlang.org/th

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
Simple question. What are the difference between an interface and a class? I'm not talking about what the compiler does with them. I'm talking about what they were created to do, how they came about etc. If you have to explain to someone what a class is and what an interface is, then you diff t

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 21:16:05 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 15:57:06 -0500, Frustrated wrote: On Thursday, 30 January 2014 at 20:17:23 UTC, Steven Schveighoffer wrote: But it's important to note that A does not define an instance of A_vtbl, just the l

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 20:17:23 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 14:58:42 -0500, Frustrated wrote: On Thursday, 30 January 2014 at 17:11:24 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 11:58:15 -0500, Frustrated wrote: Essentially what it boils down

Re: How to call opCall as template?

2014-01-30 Thread Frustrated
import std.stdio; struct B { template opCall(T) { void opCall(T x) { writeln(x); } } } template a(T) { } void main() { B a; a(3); // works because template parameter can be

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 17:11:24 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 11:58:15 -0500, Frustrated wrote: Essentially what it boils down to is treating interfaces like classes that have no fields). To avoid the diamond problem simply always choose the method that is

Re: How to call opCall as template?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 18:02:05 UTC, Namespace wrote: On Thursday, 30 January 2014 at 17:46:19 UTC, Frustrated wrote: Also, http://dlang.org/operatoroverloading.html#Dispatch and possible solution to your problem: http://www.digitalmars.com/d/archives/digitalmars/D

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 17:38:26 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 12:30:04 -0500, Frustrated wrote: On Thursday, 30 January 2014 at 17:11:24 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 11:58:15 -0500, Frustrated wrote: Essentially what it boils down

Re: How to call opCall as template?

2014-01-30 Thread Frustrated
BTW, a() is replaced with a.opCall() and you can use opDispatch on it. an opCall is a member. Either approach should work if you can get that archive example to compile.

Re: How to call opCall as template?

2014-01-30 Thread Frustrated
Also, http://dlang.org/operatoroverloading.html#Dispatch and possible solution to your problem: http://www.digitalmars.com/d/archives/digitalmars/D/opDispatch_and_template_parameters_117095.html Couldn't get code to compile though... but if it did, it should solve your problem.

Re: How to call opCall as template?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 16:53:33 UTC, Namespace wrote: On Thursday, 30 January 2014 at 16:47:46 UTC, Frustrated wrote: On Thursday, 30 January 2014 at 16:28:42 UTC, Namespace wrote: On Thursday, 30 January 2014 at 16:24:00 UTC, Stanislav Blinov wrote: void main() { F f

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 17:11:24 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 11:58:15 -0500, Frustrated wrote: Essentially what it boils down to is treating interfaces like classes that have no fields). To avoid the diamond problem simply always choose the method that is

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 15:28:24 UTC, Steven Schveighoffer wrote: On Thu, 30 Jan 2014 09:31:05 -0500, Frustrated wrote: I'm not asking about a work around but if what I am talking about can actually be done(does the vtable support this or can made to support it?) Yes. Inter

Re: How to call opCall as template?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 16:28:42 UTC, Namespace wrote: On Thursday, 30 January 2014 at 16:24:00 UTC, Stanislav Blinov wrote: void main() { F f; int i = f(3,4,5); float f_ = f!float(6, 7, 8); } Does not work, it fails with: Error: template instance f!float f

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 15:18:12 UTC, John Chapman wrote: On Thursday, 30 January 2014 at 14:31:05 UTC, Frustrated wrote: I'm not asking about a work around but if what I am talking about can actually be done(does the vtable support this or can made to support it?) It would wo

Re: Interfaces allow member definitions?

2014-01-30 Thread Frustrated
On Thursday, 30 January 2014 at 11:29:55 UTC, TheFlyingFiddle wrote: On Thursday, 30 January 2014 at 11:19:58 UTC, Frustrated wrote: I was, I think, able to call an interface's method. I had the code like the following interface A { void foo(); } class B : A { void foo() { writeln

Interfaces allow member definitions?

2014-01-30 Thread Frustrated
I was, I think, able to call an interface's method. I had the code like the following interface A { void foo(); } class B : A { void foo() { writeln("Hey"); } } class C : A { void foo() { writeln("You"); } } yet, when I called a.foo(); I did not get any output. (A being of type A) Now,

Reference parent type

2014-01-30 Thread Frustrated
Suppose I have class A { mixin t!A; } is there a way to replace the mixin template's dependence on the class name? e.g., class A { mixin t!This; // This turns in to A } (so, for example, renaming the above class only has to rename one place instead of two)

Static Factory

2014-01-29 Thread Frustrated
(Guess is didn't get sent, I guess I'm just a big spam bot cause I keep getting flagged every post) The following code demonstrates a way to have an easy factory in D requiring very little work. I imagine it can be improved to handle the abstract case(basically dependencies/constraints). Any ide

Re: automatic type creation

2014-01-27 Thread Frustrated
Here is something I just did that essentially demonstrates what I am talking about(bugs withstanding): http://dpaste.dzfl.pl/d82b6274 It is not exactly how I should be going about it as it is somewhat generic but not properly designed to allow the concrete implementations needed void main() {

Re: automatic type creation

2014-01-25 Thread Frustrated
On Sunday, 26 January 2014 at 05:19:51 UTC, Ali Çehreli wrote: Where is the tldr; section? :) On 01/25/2014 04:08 AM, Frustrated wrote: > I'd like to support extensions of my own interfaced based design > where anyone could simply "drop" in there own inherited classes &

automatic type creation

2014-01-25 Thread Frustrated
I'd like to support extensions of my own interfaced based design where anyone could simply "drop" in there own inherited classes and everything would work as if they designed everything using those classes from the get go. To do this though, I need a way to know how to generate these unknown type

Re: Compare type with another at CT

2014-01-23 Thread Frustrated
Yes, I that is what I tried initially but the error was due to that static if. Not sure why but static if (is(T : A)) { ... } static assert(0, "error"); doesn't work as the assert is called no matter what.

Compare type with another at CT

2014-01-23 Thread Frustrated
I am trying to compare a type with another type at compile time. My code is class Q(T) { static auto foo() { static if (T is A) { ... } static assert(0, "error"); } } and get the error "

Re: TLF = thread local functions

2014-01-23 Thread Frustrated
On Thursday, 23 January 2014 at 14:49:11 UTC, Dicebot wrote: On Thursday, 23 January 2014 at 14:44:01 UTC, Frustrated wrote: Functions generally are not thread safe because of reentry, right? No. They are not thread safe because they use shared data (explicitly/implicitly). Functions that

TLF = thread local functions

2014-01-23 Thread Frustrated
So, TLS solves the data issue with threading. I just thought, with out much thinking, what about having thread local functions? Doesn't make sense? Let me explain. Functions generally are not thread safe because of reentry, right? The same data is used by the function for each thread calling it a

Re: Is continuously seeding a random number generator performance intensive?

2014-01-15 Thread Frustrated
On Friday, 3 January 2014 at 13:39:41 UTC, Andrea Fontana wrote: On Friday, 3 January 2014 at 01:01:21 UTC, Frustrated wrote: On Thursday, 2 January 2014 at 20:38:10 UTC, Jeroen Bollen wrote: [...] e.g., seed(k); for(i = 1..10) print(rnd(i)); and for(i = 1..10) { seed(time); print(rnd(i

Re: Is continuously seeding a random number generator performance intensive?

2014-01-15 Thread Frustrated
On Wednesday, 15 January 2014 at 21:00:57 UTC, Jeroen Bollen wrote: How do you correctly create a MersenneTwisterEngine with a ulong as seed? If you are trying to create a very large 2D noise generator, this is how you do it, and you can any degree of smoothness you want: Create a 2D RNG. e

singleton with "momento"

2014-01-09 Thread Frustrated
Lets suppose I have setup some code to use a singleton object. Now lets suppose I want to duplicate that code(say to run multiple times simultaneously). The singleton pattern itself prevents multiple copies. One would need multiple instances to be able to run multiple times BUT in the context

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
I think maybe using alias this would not solve the problem? One would have to dispatch all the calls on the class to the array. (simply wrap the struct but prevent the compiler from thinking it is a strut so it doesn't use value semantics on it)

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
On Thursday, 9 January 2014 at 14:51:33 UTC, monarch_dodra wrote: On Thursday, 9 January 2014 at 13:32:08 UTC, Dicebot wrote: On Thursday, 9 January 2014 at 12:19:25 UTC, Frustrated wrote: I guess I see what is going on. Since Array is a struct, a local copy is made and that never ends up

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
On Thursday, 9 January 2014 at 12:15:31 UTC, Frustrated wrote: On Thursday, 9 January 2014 at 12:13:14 UTC, Frustrated wrote: I've tried insert, indexing, ~=, etc but the length always returns 0. e.g., std.container.Array!int arr; arr ~= 3; writeln(arr.length); works fine, but whe

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
On Thursday, 9 January 2014 at 12:13:14 UTC, Frustrated wrote: I've tried insert, indexing, ~=, etc but the length always returns 0. e.g., std.container.Array!int arr; arr ~= 3; writeln(arr.length); works fine, but when the array is a property of a class, it does not work, e.g., cl

Properties and std.container.Array

2014-01-09 Thread Frustrated
I've tried insert, indexing, ~=, etc but the length always returns 0. e.g., std.container.Array!int arr; arr ~= 3; writeln(arr.length); works fine, but when the array is a property of a class, it does not work, e.g., class x { std.container.Array!int _arr; @property std.container.Array!int

Re: Is continuously seeding a random number generator performance intensive?

2014-01-02 Thread Frustrated
On Thursday, 2 January 2014 at 20:38:10 UTC, Jeroen Bollen wrote: D provides a set of Random Number Generators in std.random. I am writing an application which would create a 2D map of noise. To do this though, I'll have to calculate the same random numbers over and over again. (I cannot store

Re: Determine if a member is a method

2014-01-01 Thread Frustrated
On Wednesday, 1 January 2014 at 15:10:56 UTC, Dicebot wrote: On 2014-01-01 08:43, Frustrated wrote: Also, how does one get the exact code string of a member instead of having to piece it together from info from std.traits? (which requires a lot of work)? Have a look at https://github.com

Re: Easy way to implement interface properties?

2014-01-01 Thread Frustrated
On Wednesday, 1 January 2014 at 14:30:46 UTC, Gary Willoughby wrote: On Wednesday, 1 January 2014 at 12:09:40 UTC, Jacob Carlborg wrote: On 2014-01-01 01:52, Frustrated wrote: Is there an easy way to implement properties of an interface within a class instead of having to duplicate almost the

Re: Easy way to implement interface properties?

2014-01-01 Thread Frustrated
By modifying the code I was able to achieve exactly what I wanted(I have very complex interfaces but the classes using them consist of just one line. The code basically fixes your code to handle the setter and getters better and to work with functions. It is not very robust so I won't post it

Re: Easy way to implement interface properties?

2013-12-31 Thread Frustrated
On Wednesday, 1 January 2014 at 01:55:19 UTC, Adam D. Ruppe wrote: On Wednesday, 1 January 2014 at 01:33:04 UTC, Frustrated wrote: But your template mixin is still duplicating generic code that should be easily handled automatically. (Generic properties are just wrappers around private fields

  1   2   >