Re: Derelict / SDL error

2014-12-11 Thread Paul via Digitalmars-d-learn
On Thursday, 11 December 2014 at 00:36:08 UTC, Mike Parker wrote: More evidence pointing toward the system configuration on the problem machines. I'm quite far from being a Linux guru, but at this point I would be looking at removing the binaries I've compiled myself and installing the binary

Re: Garbage collector collects live objects

2014-12-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/10/14 7:52 AM, Ruslan Mullakhmetov wrote: On Wednesday, 10 December 2014 at 08:46:12 UTC, Ruslan Mullakhmetov wrote: yes. that was the mistake. also after fixing bug in Blk Attributes printing i got more reasonable attrs for object blk: FINALIZE for array of objects blk: NO_SCAN

Re: mixin template had error by calling shared function

2014-12-11 Thread Dan Olson via Digitalmars-d-learn
Here is a way that will work. Vlasov Roman vlasovroman...@yandex.ru writes: I have this code mixin template Template(void function() func1, void function() func2) mixin template Template(alias func1, alias func2) class SomeClass { mixin Template!(func, func23); mixin

O(1) popAny for associative array?

2014-12-11 Thread Andrew Klaassen via Digitalmars-d-learn
In theory, it should be possible to do a popFront equivalent for a hash that has O(1) average complexity, so long as you don't care about order. I.e., give me any key from the hash, I don't care which one, and then delete it from the hash. Is that correct? If it is correct, is there any

Re: O(1) popAny for associative array?

2014-12-11 Thread Ali Çehreli via Digitalmars-d-learn
On 12/11/2014 10:27 AM, Andrew Klaassen wrote: If it is correct, is there any way to do it in D? Do I assume correctly that myarray.keys[0] would not meet the O(1) requirement? Correct. keys() is eager. For O(1) you want byKey(), which returns a lazy range but the code is less than pretty:

Re: O(1) popAny for associative array?

2014-12-11 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 11, 2014 at 06:27:06PM +, Andrew Klaassen via Digitalmars-d-learn wrote: In theory, it should be possible to do a popFront equivalent for a hash that has O(1) average complexity, so long as you don't care about order. I.e., give me any key from the hash, I don't care which

Re: Garbage collector collects live objects

2014-12-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/10/14 7:52 AM, Ruslan Mullakhmetov wrote: On Wednesday, 10 December 2014 at 08:46:12 UTC, Ruslan Mullakhmetov wrote: yes. that was the mistake. also after fixing bug in Blk Attributes printing i got more reasonable attrs for object blk: FINALIZE for array of objects blk: NO_SCAN

Re: O(1) popAny for associative array?

2014-12-11 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 11, 2014 at 10:36:02AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] auto mykey = myarray.byKey().front; myarray.remove(mykey); [...] Ah, I forgot that you need to check .empty on the range returned by byKey before accessing .front. Thanks to Ali for pointing

Re: O(1) popAny for associative array?

2014-12-11 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: On the other hand, AA.byKey() will return a *lazy* sequence of keys (i.e., it won't actually walk the AA unless you want it to), so doing this ought to be O(1): auto mykey = myarray.byKey().front; myarray.remove(mykey); In general the associative array table can

Re: O(1) popAny for associative array?

2014-12-11 Thread Andrew Klaassen via Digitalmars-d-learn
Thanks everyone!

File Not Found: pq.lib

2014-12-11 Thread Suliman via Digitalmars-d-learn
I am trying to start with http://code.dlang.org/packages/dpq2 But I can't understand where I should to get pq.lib and where I should to place it. In the Program Files I did not find such file...

stdio.lines doesn't have popFront, but works with foreach

2014-12-11 Thread Andrew Klaassen via Digitalmars-d-learn
The docs for stdio.lines say that it's a struct. stdio.lines works with foreach. The docs for foreach say: Iteration over struct and class objects can be done with ranges. For foreach, this means the following properties and methods must be defined: .empty ... .front ... .popFront() But

Re: stdio.lines doesn't have popFront, but works with foreach

2014-12-11 Thread bearophile via Digitalmars-d-learn
Andrew Klaassen: The docs for stdio.lines say that it's a struct. stdio.lines works with foreach. If you want a range use myfile.File.byLine or myfile.File.byLineCopy. Bye, bearophile

Re: stdio.lines doesn't have popFront, but works with foreach

2014-12-11 Thread Andrew Klaassen via Digitalmars-d-learn
On Thursday, 11 December 2014 at 20:17:50 UTC, bearophile wrote: Andrew Klaassen: The docs for stdio.lines say that it's a struct. stdio.lines works with foreach. If you want a range use myfile.File.byLine or myfile.File.byLineCopy. Bye, bearophile I know that there are other ways

Re: stdio.lines doesn't have popFront, but works with foreach

2014-12-11 Thread Kapps via Digitalmars-d-learn
On Thursday, 11 December 2014 at 20:11:21 UTC, Andrew Klaassen wrote: The docs for stdio.lines say that it's a struct. stdio.lines works with foreach. The docs for foreach say: Iteration over struct and class objects can be done with ranges. For foreach, this means the following properties

scope block do not handle failure, but try-catch does

2014-12-11 Thread Suliman via Digitalmars-d-learn
string dbname = config.getKey(dbname1); scope(failure) writeln(look like dbname is missing); I am using dini and trying to throw exception if value can't be extract from config. If I am wrap it's in try-сефср block it's work or. But in this situation scope block do not execute and I see only

Global array

2014-12-11 Thread Paul via Digitalmars-d-learn
Is there any merit (or folly!) in storing a large array, that frequently needs to be accessed globally, within a class like so: public class classMap{ public static int[MAPSIZE][MAPSIZE] map; } Or is there a proper 'D' way to do this? TIA

Re: stdio.lines doesn't have popFront, but works with foreach

2014-12-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/11/14 3:21 PM, Andrew Klaassen wrote: On Thursday, 11 December 2014 at 20:17:50 UTC, bearophile wrote: Andrew Klaassen: The docs for stdio.lines say that it's a struct. stdio.lines works with foreach. If you want a range use myfile.File.byLine or myfile.File.byLineCopy. Bye,

Re: scope block do not handle failure, but try-catch does

2014-12-11 Thread Michael via Digitalmars-d-learn
On Thursday, 11 December 2014 at 20:40:40 UTC, Suliman wrote: string dbname = config.getKey(dbname1); scope(failure) writeln(look like dbname is missing); I am using dini and trying to throw exception if value can't be extract from config. If I am wrap it's in try-сефср block it's work or.

Re: Global array

2014-12-11 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 11, 2014 at 08:56:00PM +, Paul via Digitalmars-d-learn wrote: Is there any merit (or folly!) in storing a large array, that frequently needs to be accessed globally, within a class like so: public class classMap{ public static int[MAPSIZE][MAPSIZE] map; }

Re: stdio.lines doesn't have popFront, but works with foreach

2014-12-11 Thread Andrew Klaassen via Digitalmars-d-learn
On Thursday, 11 December 2014 at 20:37:09 UTC, Kapps wrote: Ranges are one way of allowing foreach. The other is through the use of opApply, which is what std.stdio.lines does. http://dlang.org/statement.html#ForeachStatement Ah, so I just needed to keep reading down a few lines in the

dub dustmite

2014-12-11 Thread Vlad Levenfeld via Digitalmars-d-learn
I'm trying to reduce a bug with dub dustmite feature and I must be doing it wrong somehow, my regular dub output looks like this: source/experimental.d(2403): Error: struct experimental.Product!(int[], int[]).Product no size yet for forward reference ulong[2] source/experimental.d(2454):

Allocating aligned memory blocks?

2014-12-11 Thread H. S. Teoh via Digitalmars-d-learn
Hi all, I'm working on a very large associative array implementation that stores most of the data on disk, and I need to allocate a number of cache areas for keeping hot disk pages in RAM. Is there a way to allocate GC memory blocks in D that are guaranteed to fall on OS page boundaries? Or

Re: Allocating aligned memory blocks?

2014-12-11 Thread safety0ff via Digitalmars-d-learn
On Friday, 12 December 2014 at 06:17:56 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Is there a way to allocate GC memory blocks in D that are guaranteed to fall on OS page boundaries? I don't know about guarantees, I think that in practice, if your OS page size is 4096, any GC allocation

Re: dub dustmite

2014-12-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 2014-12-12 05:25, Vlad Levenfeld wrote: I get Executing dustmite... None = No object.Exception@dustmite.d(243): Initial test fails It seems like a pretty simple case, I'm not sure what's going on. I get the same error as well every time I use dustmite. At lease via Dub. --