Re: Indivisual Incremental Compalation with dub

2015-08-13 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 13 August 2015 at 05:42:38 UTC, Freddy wrote: I have a file that takes a while to compile with a static interface. Is there any way i can make dub keep the object file of only that file(for faster compilation)? I don't think dub itself can do this, but

Re: SList container problem

2015-08-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 13 August 2015 at 08:40:13 UTC, ted wrote: have upgraded from 2.066.1 to 2.068.0, and have a change in behaviour: import std.container: SList; void main() { SList!int tmp; tmp.insertAfter( tmp[], 3 ); } used to work happily with dmd2.066.1, causes assert

SList container problem

2015-08-13 Thread ted via Digitalmars-d-learn
have upgraded from 2.066.1 to 2.068.0, and have a change in behaviour: import std.container: SList; void main() { SList!int tmp; tmp.insertAfter( tmp[], 3 ); } used to work happily with dmd2.066.1, causes assert (core.exception.AssertError@std/container/slist.d(57): Assertion

vs2015 linker error

2015-08-13 Thread learn via Digitalmars-d-learn
trying to comile the minimal console application generated by visuald: Building Debug\ConsoleApp1.exe... LINK : fatal error LNK1104: cannot open file 'libucrtd.lib' Building Debug\ConsoleApp1.exe failed!

Re: Code Reviewer

2015-08-13 Thread Clayton via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 13:14:04 UTC, sigod wrote: On Tuesday, 11 August 2015 at 22:50:52 UTC, Clayton wrote: Hello everyone, Am looking for someone who could help review my code . As an entry exercise to D am converting 3 C implementations of popular pattern matching algorithms.

Re: Code Reviewer

2015-08-13 Thread Clayton via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 12:14:20 UTC, Rikki Cattermole wrote: On 13/08/2015 12:09 a.m., Clayton wrote: On Wednesday, 12 August 2015 at 02:49:59 UTC, Rikki Cattermole wrote: On 12/08/2015 10:50 a.m., Clayton wrote: [...] Upload to e.g. Github/gist/pastebin. Hi Rikki, can I have

Re: Code Reviewer

2015-08-13 Thread Rikki Cattermole via Digitalmars-d-learn
On 12/08/2015 10:50 a.m., Clayton wrote: Hello everyone, Am looking for someone who could help review my code . As an entry exercise to D am converting 3 C implementations of popular pattern matching algorithms. The idea is to have 6 final implementations ( 3 compile-time and 3 runtime) . I

Re: Structs and compiletime evaluation

2015-08-13 Thread D_Learner via Digitalmars-d-learn
On Thursday, 13 August 2015 at 12:21:44 UTC, Rikki Cattermole wrote: On Thursday, 13 August 2015 at 12:07:48 UTC, D_Learner wrote: I am having this struct :- struct COMPILETIME_BM_PRE { void initialisebmBc(S,C,I,int k)( const S pattern ,ref I[C] bmBc){ static

Re: Structs and compiletime evaluation

2015-08-13 Thread Rikki Cattermole via Digitalmars-d-learn
On Thursday, 13 August 2015 at 12:07:48 UTC, D_Learner wrote: I am having this struct :- struct COMPILETIME_BM_PRE { void initialisebmBc(S,C,I,int k)( const S pattern ,ref I[C] bmBc){ static if ( k ASIZE ){ bmBc[ALPHABET[k]] = size;

Structs and compiletime evaluation

2015-08-13 Thread D_Learner via Digitalmars-d-learn
I am having this struct :- struct COMPILETIME_BM_PRE { void initialisebmBc(S,C,I,int k)( const S pattern ,ref I[C] bmBc){ static if ( k ASIZE ){ bmBc[ALPHABET[k]] = size; initialisebmBc!(S,C,I,k+1)( pattern

Re: Structs and compiletime evaluation

2015-08-13 Thread Rikki Cattermole via Digitalmars-d-learn
On 14/08/2015 12:48 a.m., D_Learner wrote: On Thursday, 13 August 2015 at 12:21:44 UTC, Rikki Cattermole wrote: On Thursday, 13 August 2015 at 12:07:48 UTC, D_Learner wrote: I am having this struct :- struct COMPILETIME_BM_PRE { void initialisebmBc(S,C,I,int k)( const S

Re: Attributes not propagating to objects via typeinfo?

2015-08-13 Thread rsw0x via Digitalmars-d-learn
On Thursday, 13 August 2015 at 03:46:19 UTC, rsw0x wrote: Sample code: class C{} struct S{} void main(){ import std.stdio; auto c = new shared C(); auto s = new shared S(); writeln(typeid(c)); //modulename.C writeln(typeid(s)); //shared(modulename.S)*

complete win headers for 32/64 bit

2015-08-13 Thread learn via Digitalmars-d-learn
unfortunately i can't find a complete set of windows header files. maybe one should add a link for those headers if they exist - life is not linux or osx only.

Re: complete win headers for 32/64 bit

2015-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 August 2015 at 16:28:15 UTC, learn wrote: unfortunately i can't find a complete set of windows header files. maybe one should add a link for those headers if they exist - life is not linux or osx only. I'm slowly working on getting them into the standard library. I'm probably

Re: complete win headers for 32/64 bit

2015-08-13 Thread learn via Digitalmars-d-learn
On Thursday, 13 August 2015 at 17:04:54 UTC, Adam D. Ruppe wrote: On Thursday, 13 August 2015 at 16:28:15 UTC, learn wrote: I'm slowly working on getting them into the standard library. I'm probably one or two more weekends away from getting it to work (it is harder than I thought because the

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Jack Stouffer via Digitalmars-d-learn
On Thursday, 13 August 2015 at 20:28:33 UTC, Adam D. Ruppe wrote: On Thursday, 13 August 2015 at 20:23:56 UTC, Jack Stouffer wrote: As far as I can tell, there is no way to know the actual type of each of the objects in the list to be able to print: Cast it to Object first, then do the typeid

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Jack Stouffer via Digitalmars-d-learn
On Thursday, 13 August 2015 at 22:20:35 UTC, Justin Whear wrote: foreach (item; parent_list) { if (auto asA = cast(A)item) { asA.method(); } else if (auto asB = cast(B)item) { asB.method2(); } } On Thursday, 13 August 2015 at 22:20:35 UTC, Justin Whear wrote: Thanks Justin and

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread rumbu via Digitalmars-d-learn
On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer wrote: Thanks, that worked, and based on your answer, I was able to fix my real problem: dynamically calling different methods on each object in the list based on its type. So, using the above code as an example, I am able to call

Yieldable function?

2015-08-13 Thread Tofu Ninja via Digitalmars-d-learn
Is there any way to have a yieldable function that can be resumed at a later time in D? Some thing like: void test() { writeln(A); yeild(); writeln(B); } ... auto x = yieldable!test(); x.resume(); // prints A x.resume(); // prints B x.resume(); // throws an error or something,

Re: Yieldable function?

2015-08-13 Thread MrSmith via Digitalmars-d-learn
http://dlang.org/phobos/core_thread.html#.Fiber

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Jack Stouffer via Digitalmars-d-learn
On Friday, 14 August 2015 at 00:06:33 UTC, Adam D. Ruppe wrote: On Thursday, 13 August 2015 at 23:48:08 UTC, Jack Stouffer wrote: In my code, the list can have 20-30 different types of classes in it all inheriting from the same interface, and it doesn't make sense for all of those classes to

Re: Yieldable function?

2015-08-13 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 13 August 2015 at 22:29:17 UTC, MrSmith wrote: http://dlang.org/phobos/core_thread.html#.Fiber Man I feel like I saw that before but when I went looking for it I couldn't find it. Didn't think to check in core. :/ Welp that solves my question, thanks :D

Re: Yieldable function?

2015-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 August 2015 at 22:27:31 UTC, Tofu Ninja wrote: Also how portable is the built in asm support it varies a bit across compilers (gdc does it differently), and obviously across processors. Also is there a way to define naked functions in D? Put the `naked;`

Re: Yieldable function?

2015-08-13 Thread Ali Çehreli via Digitalmars-d-learn
On 08/13/2015 03:36 PM, Tofu Ninja wrote: On Thursday, 13 August 2015 at 22:29:17 UTC, MrSmith wrote: http://dlang.org/phobos/core_thread.html#.Fiber Man I feel like I saw that before but when I went looking for it I couldn't find it. Didn't think to check in core. :/ Welp that solves my

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 August 2015 at 23:48:08 UTC, Jack Stouffer wrote: In my code, the list can have 20-30 different types of classes in it all inheriting from the same interface, and it doesn't make sense for all of those classes to implement a method that is very specific to one of the classes.

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Ali Çehreli via Digitalmars-d-learn
On 08/13/2015 04:48 PM, Jack Stouffer wrote: On Thursday, 13 August 2015 at 22:49:15 UTC, Adam D. Ruppe wrote: On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer wrote: dynamically calling different methods on each object in the list based on its type. The cleanest OO way of doing

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer wrote: dynamically calling different methods on each object in the list based on its type. The cleanest OO way of doing that is to put the methods you need in the interface and always call it through that. Then there's no need to

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Justin Whear via Digitalmars-d-learn
On Thu, 13 Aug 2015 21:42:52 +, Jack Stouffer wrote: foreach (item; parent_list) { string class_name = (cast(Object) item).classinfo.name; if (class_name == test.A) { (cast(A) item).method(); } else if

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Jack Stouffer via Digitalmars-d-learn
On Thursday, 13 August 2015 at 22:49:15 UTC, Adam D. Ruppe wrote: On Thursday, 13 August 2015 at 21:42:54 UTC, Jack Stouffer wrote: dynamically calling different methods on each object in the list based on its type. The cleanest OO way of doing that is to put the methods you need in the

Compiletime Table

2015-08-13 Thread D_Learner via Digitalmars-d-learn
I was wondering how I could change the code below such the `bmBc` is computed at compile time . The one below works for runtime but it is not ideal since I need to know the `bmBc` table at compile-time . I could appreciate advice on how I could improve on this. import std.conv:to;

Re: Compiletime Table

2015-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 August 2015 at 19:13:55 UTC, D_Learner wrote: I was wondering how I could change the code below such the `bmBc` is computed at compile time . It is currently not possible to build an associative array at compile time and keep it as a runtime table due to the implementation.

How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Jack Stouffer via Digitalmars-d-learn
Given: interface Parent { void method(); } class A : Parent { void method() {} this() {} } class B : Parent { void method() {} void method2() {} this() {} } void main() { import std.stdio; Parent[]

Re: complete win headers for 32/64 bit

2015-08-13 Thread anonymous via Digitalmars-d-learn
On Thursday, 13 August 2015 at 16:28:15 UTC, learn wrote: unfortunately i can't find a complete set of windows header files. maybe one should add a link for those headers if they exist - life is not linux or osx only. https://github.com/etcimon/windows-headers

Re: How do I find the actual types of the elements in a list of classes?

2015-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 August 2015 at 20:23:56 UTC, Jack Stouffer wrote: As far as I can tell, there is no way to know the actual type of each of the objects in the list to be able to print: Cast it to Object first, then do the typeid and it will get the dynamic class type. Since Parent is an

Re: Compiletime Table

2015-08-13 Thread anonymous via Digitalmars-d-learn
On Thursday, 13 August 2015 at 19:13:55 UTC, D_Learner wrote: I was wondering how I could change the code below such the `bmBc` is computed at compile time . The one below works for runtime but it is not ideal since I need to know the `bmBc` table at compile-time . I could appreciate advice

Re: Compiletime Table

2015-08-13 Thread D_Learner via Digitalmars-d-learn
On Thursday, 13 August 2015 at 19:26:12 UTC, Adam D. Ruppe wrote: On Thursday, 13 August 2015 at 19:13:55 UTC, D_Learner wrote: I was wondering how I could change the code below such the `bmBc` is computed at compile time . It is currently not possible to build an associative array at

Re: iterating through a range, operating on last few elements at a time

2015-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Aug 14, 2015 at 02:42:26AM +, Laeeth Isharc via Digitalmars-d-learn wrote: I have a range that is an array of structs. I would like to iterate through the range, calling a function with the prior k items in the range up to that point and storing the result of the function in a new

iterating through a range, operating on last few elements at a time

2015-08-13 Thread Laeeth Isharc via Digitalmars-d-learn
I have a range that is an array of structs. I would like to iterate through the range, calling a function with the prior k items in the range up to that point and storing the result of the function in a new range/array. what's the best way to do this? for low fixed k I could use zip with

Re: Attributes not propagating to objects via typeinfo?

2015-08-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/13/15 11:59 AM, Steven Schveighoffer wrote: That is definitely a bug. It's because typeid is looking up the derived type via the vtable, but the compiler should rewrap it with 'shared' afterwards. Actually, now that I think about it, I'm not sure how the compiler can figure this out.

Re: Attributes not propagating to objects via typeinfo?

2015-08-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/12/15 11:46 PM, rsw0x wrote: Sample code: class C{} struct S{} void main(){ import std.stdio; auto c = new shared C(); auto s = new shared S(); writeln(typeid(c)); //modulename.C writeln(typeid(s)); //shared(modulename.S)* writeln(typeid(c).next); //null