Re: SList container problem

2015-08-14 Thread ted via Digitalmars-d-learn
thanks for the reply... the method you described is suitable for appending to an array, but I'm using the singly-linked-list container. I've extended the test, and I'm pretty sure it's a bug... --ted Nicholas Wilson wrote: On Thursday, 13 August 2015 at 08:40:13 UTC, ted wrote: have

Associative array literal. Why doesn't it compile?

2015-08-14 Thread Adel Mamin via Digitalmars-d-learn
Compiler dmd_2.068.0-0_amd64.deb on Ubuntu 12.04 Linux: auto lookup = [ one:1, two:2 ]; The dmd error: Error: non-constant expression [one:1, two:2] Why doesn't it compile? As a workaround I could do the assignment one element at a time in a loop. It would be uglier though.

Re: Associative array literal. Why doesn't it compile?

2015-08-14 Thread Ali Çehreli via Digitalmars-d-learn
On 08/13/2015 11:48 PM, Adel Mamin wrote: Compiler dmd_2.068.0-0_amd64.deb on Ubuntu 12.04 Linux: auto lookup = [ one:1, two:2 ]; The dmd error: Error: non-constant expression [one:1, two:2] I think the problem is when the variable is defined at module scope. It works inside functions, etc.

Re: Associative array literal. Why doesn't it compile?

2015-08-14 Thread BBasile via Digitalmars-d-learn
On Friday, 14 August 2015 at 06:48:27 UTC, Adel Mamin wrote: Compiler dmd_2.068.0-0_amd64.deb on Ubuntu 12.04 Linux: auto lookup = [ one:1, two:2 ]; The dmd error: Error: non-constant expression [one:1, two:2] Why doesn't it compile? As a workaround I could do the assignment one element at a

Re: More threads - Slower program ??

2015-08-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 23:23:03 UTC, Yuxuan Shui wrote: Is there a way to do thread-local allocations? Yes, either manually or just putting things on the stack, but the std.string functions you use doesn't try to do them. You might try replacing format() with formattedWrite(),

Re: Associative array literal. Why doesn't it compile?

2015-08-14 Thread anonymous via Digitalmars-d-learn
On Friday, 14 August 2015 at 07:04:53 UTC, BBasile wrote: It's because of the key type (string is a library type). This is not true. It's not because of the key type. And string is not a library type.

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

2015-08-14 Thread Timon Gehr via Digitalmars-d-learn
On 08/14/2015 05:12 AM, H. S. Teoh via Digitalmars-d-learn wrote: 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

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

2015-08-14 Thread Timon Gehr via Digitalmars-d-learn
On 08/14/2015 03:26 PM, Timon Gehr wrote: On 08/14/2015 05:12 AM, H. S. Teoh via Digitalmars-d-learn wrote: ... I didn't figure out how to eliminate the short slices toward the end, ... :o) ... Less hacky and less efficient: auto slidingWindow(R)(R range, int k) { return

Theoretical Best Practices

2015-08-14 Thread DarthCthulhu via Digitalmars-d-learn
This is more a theoretical exercise than specific code nitty gritty, but... Let's say I have some code like this: class World { // Bunch of members and other functions void happyDay () { if (bCthulhuRises) { debug(logging) {

dub and subpackages

2015-08-14 Thread yawniek via Digitalmars-d-learn
i'm trying to have my own versions of my dependencies as git submodules. problem: i include a local version of vibe.d and then i add other local versions of packages that themselves include vibe.d somehow my version of vibe isn't picked up by the other dependencies and it results in an

Re: dub and subpackages

2015-08-14 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 14 August 2015 at 08:06:15 UTC, yawniek wrote: i'm trying to have my own versions of my dependencies as git submodules. whats the correct way of having a chain of packages included from git submodules so that every packages get's only picked once? dub add-local allows you to

Re: Attributes not propagating to objects via typeinfo?

2015-08-14 Thread via Digitalmars-d-learn
On Thursday, 13 August 2015 at 16:05:19 UTC, Steven Schveighoffer wrote: 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

Re: dub and subpackages

2015-08-14 Thread yawniek via Digitalmars-d-learn
On Friday, 14 August 2015 at 08:09:18 UTC, Edwin van Leeuwen wrote: On Friday, 14 August 2015 at 08:06:15 UTC, yawniek wrote: dub add-local allows you to add local copy of a package. This will be system wide though, not only for the current package. i actually tried this, somehow did't work

Re: Associative array literal. Why doesn't it compile?

2015-08-14 Thread Temtaime via Digitalmars-d-learn
It's because it's implemented in DMD only partly. There's a bug report associated with it.

Re: Attributes not propagating to objects via typeinfo?

2015-08-14 Thread Timon Gehr via Digitalmars-d-learn
On 08/13/2015 06:05 PM, Steven Schveighoffer wrote: 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,

Re: Attributes not propagating to objects via typeinfo?

2015-08-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/14/15 11:39 AM, Timon Gehr wrote: On 08/13/2015 06:05 PM, Steven Schveighoffer wrote: 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.

Re: Compiletime Table

2015-08-14 Thread D_Learner via Digitalmars-d-learn
On Friday, 14 August 2015 at 20:48:43 UTC, Adam D. Ruppe wrote: On Friday, 14 August 2015 at 20:40:13 UTC, D_Learner wrote: Perhaps I have to get myself a copy. you should! There's a lot of little tips and tricks in there. Am currently looking at your Dconf2015 talk . My blasphemous talk

Re: Theoretical Best Practices

2015-08-14 Thread DarthCthulhu via Digitalmars-d-learn
On Friday, 14 August 2015 at 12:40:08 UTC, Steven Schveighoffer wrote: I would do it this way: // at module level debug(logging) { Logger logger; static this() { logger = new Logger;} } If you want to have the logger be global, add 'shared' to both the logger and the static this.

Re: Compiletime Table

2015-08-14 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: [...] It is currently not possible to build an associative array at compile time and keep it as a runtime table due to the implementation. [...] Am aware you

Re: Compiletime Table

2015-08-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 14 August 2015 at 20:40:13 UTC, D_Learner wrote: Perhaps I have to get myself a copy. you should! There's a lot of little tips and tricks in there. Am currently looking at your Dconf2015 talk . My blasphemous talk as I like to call it :) There's a bit in the video where i went

Re: Compiletime Table

2015-08-14 Thread D_Learner via Digitalmars-d-learn
On Thursday, 13 August 2015 at 19:54:18 UTC, anonymous wrote: On Thursday, 13 August 2015 at 19:13:55 UTC, D_Learner wrote: [...] I think you may have some fundamental misunderstandings regarding CTFE, templates, etc. Your code seems to be half-way between a template-based and a

Re: Theoretical Best Practices

2015-08-14 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 14 August 2015 at 22:25:15 UTC, DarthCthulhu wrote: Ahh, that is a much cleaner way to do it rather than using a singleton. By 'module level', I assume you mean in the module that defines the Logger class? An 'import debug.logger' or somesuch would then give all relevant modules

Re: Theoretical Best Practices

2015-08-14 Thread DarthCthulhu via Digitalmars-d-learn
On Friday, 14 August 2015 at 23:17:44 UTC, Tofu Ninja wrote: On Friday, 14 August 2015 at 22:25:15 UTC, DarthCthulhu wrote: Ahh, that is a much cleaner way to do it rather than using a singleton. By 'module level', I assume you mean in the module that defines the Logger class? An 'import

Re: using memset withing a pure function

2015-08-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 August 2015 at 01:09:15 UTC, D_Learner wrote: When writting a pure fucntion involving C non pure functions like memcpy() and memset() Those functions are pure already, and marked so in the newest dmd (and I think older ones too, though I haven't confirmed. Your code

Re: using memset withing a pure function

2015-08-14 Thread anonymous via Digitalmars-d-learn
On Saturday, 15 August 2015 at 02:21:46 UTC, D_Learner wrote: Well, the actual error I got is : Error: memset cannot be interpreted at compile time, because it has no available source code . I seems to suggest I miss the actual code. I guess I gave you a wrong impression of how pure relates

Re: using memset withing a pure function

2015-08-14 Thread Ali Çehreli via Digitalmars-d-learn
On 08/14/2015 06:09 PM, D_Learner wrote: When writting a pure fucntion involving C non pure functions If you want to live dangerously, you can use assumePure, which is found in one of the unittest blocks of std.traits: import std.traits; auto assumePure(T)(T t) if (isFunctionPointer!T ||

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

2015-08-14 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 14 August 2015 at 13:32:57 UTC, Timon Gehr wrote: On 08/14/2015 03:26 PM, Timon Gehr wrote: On 08/14/2015 05:12 AM, H. S. Teoh via Digitalmars-d-learn wrote: ... I didn't figure out how to eliminate the short slices toward the end, ... :o) ... Less hacky and less efficient:

Re: using memset withing a pure function

2015-08-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 August 2015 at 02:21:46 UTC, D_Learner wrote: Well, the actual error I got is : Error: memset cannot be interpreted at compile time, because it has no available source code . I seems to suggest I miss the actual code. yeah, ctfe is different than pure functions. That's where

Re: using memset withing a pure function

2015-08-14 Thread anonymous via Digitalmars-d-learn
On Saturday, 15 August 2015 at 02:21:46 UTC, D_Learner wrote: On Saturday, 15 August 2015 at 01:13:02 UTC, Adam D. Ruppe wrote: On Saturday, 15 August 2015 at 01:09:15 UTC, D_Learner wrote: When writting a pure fucntion involving C non pure functions like memcpy() and memset() Those

using memset withing a pure function

2015-08-14 Thread D_Learner via Digitalmars-d-learn
When writting a pure fucntion involving C non pure functions like memcpy() and memset() , what could be the way around? Should I re-write these and make them pure? The code am converting is as below :- int ag_cmatch(const string pattern, const string text, int[char] bmBc , int[size]

Re: using memset withing a pure function

2015-08-14 Thread D_Learner via Digitalmars-d-learn
On Saturday, 15 August 2015 at 01:13:02 UTC, Adam D. Ruppe wrote: On Saturday, 15 August 2015 at 01:09:15 UTC, D_Learner wrote: When writting a pure fucntion involving C non pure functions like memcpy() and memset() Those functions are pure already, and marked so in the newest dmd (and I

Re: complete win headers for 32/64 bit

2015-08-14 Thread Kagamin via Digitalmars-d-learn
http://code.dlang.org/packages/windows-headers - as a dub package.

Re: SList container problem

2015-08-14 Thread anonymous via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=14920

Re: Attributes not propagating to objects via typeinfo?

2015-08-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/14/15 4:22 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Thursday, 13 August 2015 at 16:05:19 UTC, Steven Schveighoffer wrote: 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

Re: Theoretical Best Practices

2015-08-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/14/15 5:21 AM, DarthCthulhu wrote: This is more a theoretical exercise than specific code nitty gritty, but... Let's say I have some code like this: class World { // Bunch of members and other functions void happyDay () { if (bCthulhuRises) {

Re: Theoretical Best Practices

2015-08-14 Thread QAston via Digitalmars-d-learn
On Friday, 14 August 2015 at 09:21:56 UTC, DarthCthulhu wrote: I only want to access the logger object when the program is compiled with the -debug option, so I don't want to pass it along to the object constructor or set a member as a reference to it (which is both tedious and pointless if