detaching a thread from druntime <2.067

2014-12-15 Thread Ellery Newcomer via Digitalmars-d-learn
If I have a thread that I need to detach from druntime, I can call thread_detachInstance, but for 2.066, this function does not exist. Is there any way to do this in 2.066? I notice there is a thread_detachByAddr, but I'm not sure how to get a ThreadAddr out of a Thread..

Re: I want to implement operation feasible?

2014-12-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 16 December 2014 at 04:45:31 UTC, Brian wrote: interface BaseMod { auto getInstance(); } You can't do that - interface methods must be either final or have concrete types (they can't be templates or auto returns). Make it BaseMod getInstance(); and the rest of your classe

I want to implement operation feasible?

2014-12-15 Thread Brian via Digitalmars-d-learn
package com.kerisy.mod.base interface BaseMod { auto getInstance(); } package com.kerisy.mod.a class A : BaseMod { A getInstance() { return (new A); } void hello() { // in A writeln("in A")

Re: Problem calling extern(C) function

2014-12-15 Thread AuoroP via Digitalmars-d-learn
Thank you!!! All I have to do is > -Original Message- > From: digitalmars-d-learn@puremagic.com > Sent: Mon, 15 Dec 2014 17:54:51 + > To: digitalmars-d-learn@puremagic.com > Subject: Re: Problem calling extern(C) function > > On Monday, 15 December 2014 at 17:48:32 UTC, AuoroP via

Re: mixin template and const property qualifier?

2014-12-15 Thread anonymous via Digitalmars-d-learn
On Monday, 15 December 2014 at 23:14:30 UTC, aldanor wrote: Could someone please explain why the following doesn't compile with "const" qualifier while it does work without it? /* test.d */ module test; mixin template Foo() { mixin("@property int bar() const { return foo; }"); } int foo

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread bearophile via Digitalmars-d-learn
Nordlöw: BTW: Why doesn't aa.byKey.map work? It currently works. Bye, bearophile

mixin template and const property qualifier?

2014-12-15 Thread aldanor via Digitalmars-d-learn
Could someone please explain why the following doesn't compile with "const" qualifier while it does work without it? /* test.d */ module test; mixin template Foo() { mixin("@property int bar() const { return foo; }"); } int foo = 1; mixin Foo; unittest { assert(foo == bar); } rdmd

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread Nordlöw
On Monday, 15 December 2014 at 22:58:43 UTC, Nordlöw wrote: Tuple!(Key,Value)[] pairs(Key,Value)(Value[Key] aa); a suitable contender for now? I especially wonder about the mutability of parameter aa. More specifically is https://github.com/nordlow/justd/blob/master/range_ex.d#L545 ok?

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread Nordlöw
On Monday, 15 December 2014 at 14:41:43 UTC, bearophile wrote: Nordlöw: Is there a combined property of AAs that combine keys and values typically .pairs() or .byPairs() I need to sort the elements of an AA by value and then retrieved corresponding keys in the order sorted. You can add

Re: Odd Error Message

2014-12-15 Thread ketmar via Digitalmars-d-learn
On Mon, 15 Dec 2014 22:09:28 + CraigDillabaugh via Digitalmars-d-learn wrote: > Given the following program: > > import std.string; > import std.stdio; > > void main() > { > File file = File("blah.txt", "r"); > > while( !(file.eof()) && count > 10 ) { //line 8 >

Re: Odd Error Message

2014-12-15 Thread bearophile via Digitalmars-d-learn
CraigDillabaugh: Given the following program: import std.string; import std.stdio; void main() { File file = File("blah.txt", "r"); while( !(file.eof()) && count > 10 ) { //line 8 // } } I get the error message: line(8): Error: void ha

Odd Error Message

2014-12-15 Thread CraigDillabaugh via Digitalmars-d-learn
Given the following program: import std.string; import std.stdio; void main() { File file = File("blah.txt", "r"); while( !(file.eof()) && count > 10 ) { //line 8 // } } I get the error message: line(8): Error: void has no value If I co

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread ketmar via Digitalmars-d-learn
On Mon, 15 Dec 2014 21:32:23 + Meta via Digitalmars-d-learn wrote: > On Monday, 15 December 2014 at 18:55:13 UTC, bearophile wrote: > >> Now this yields tuples: > >> assert(aa.byPair!Tuple.array == aa.pairs!Tuple); > > > > But I'd really like tuples as built-ins for D -.- This is a > > work-

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread Meta via Digitalmars-d-learn
On Monday, 15 December 2014 at 18:55:13 UTC, bearophile wrote: Now this yields tuples: assert(aa.byPair!Tuple.array == aa.pairs!Tuple); But I'd really like tuples as built-ins for D -.- This is a work-around that cements the ugly Phobos tuples in the language... -.- Bye, bearophile Kenji

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-15 Thread Nordlöw
On Monday, 15 December 2014 at 15:55:22 UTC, Steven Schveighoffer wrote: What's the fastest way to append multiple elements to an array?: Before appending, call reserve to avoid the possibility of reallocating multiple times: arr.reserve(arr.length + n); // about to append n elements. Than

Re: Are there any methods like isDestroyed or isDisposed to detect whether some object is destroyed or not?

2014-12-15 Thread Andrey Derzhavin via Digitalmars-d-learn
Thank you very much, Steven!

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 15, 2014 at 06:46:20PM +, bearophile via Digitalmars-d-learn wrote: > H. S. Teoh: > > >I implemented this before, but it got rejected because people > >insisted that it must return a range of Tuple, but Tuple is defined > >in Phobos and druntime can't have dependencies on Phobos.

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread bearophile via Digitalmars-d-learn
Now this yields tuples: assert(aa.byPair!Tuple.array == aa.pairs!Tuple); But I'd really like tuples as built-ins for D -.- This is a work-around that cements the ugly Phobos tuples in the language... -.- Bye, bearophile

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread ketmar via Digitalmars-d-learn
On Mon, 15 Dec 2014 13:47:58 -0500 Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/15/14 1:10 PM, ketmar via Digitalmars-d-learn wrote: > > On Mon, 15 Dec 2014 13:01:10 -0500 > > Steven Schveighoffer via Digitalmars-d-learn > > wrote: > > > >>> but i agree that this > >>> requirement

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread bearophile via Digitalmars-d-learn
One possible solution: Another idea is to make "byPair" and "pairs" templates that by default return 2-structs and use a Tuple on request (so you have to import Phobos Tuple if you want them, so byPair doesn't depend on Phobos and you can put in druntime): int[string] aa; assert(aa.byPair.a

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread ketmar via Digitalmars-d-learn
On Mon, 15 Dec 2014 18:42:11 + bearophile via Digitalmars-d-learn wrote: > ketmar: > > > the only way to get it into the specs is to write the useful > > library that relies on that behavior and then scream "don't > > break our code, it's regression!" then it eventually may be > > turned to

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/15/14 1:10 PM, ketmar via Digitalmars-d-learn wrote: On Mon, 15 Dec 2014 13:01:10 -0500 Steven Schveighoffer via Digitalmars-d-learn wrote: but i agree that this requirement should be documented. and i bet it will not, 'cause this will support principle of least astonishment, which is co

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread bearophile via Digitalmars-d-learn
H. S. Teoh: I implemented this before, but it got rejected because people insisted that it must return a range of Tuple, but Tuple is defined in Phobos and druntime can't have dependencies on Phobos. :-( Maybe I'll take another shot at this, since this question keeps coming up. One possibl

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread bearophile via Digitalmars-d-learn
ketmar: the only way to get it into the specs is to write the useful library that relies on that behavior and then scream "don't break our code, it's regression!" then it eventually may be turned to requirement and documented. This is a bad idea. Bye, bearophile

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread ketmar via Digitalmars-d-learn
On Mon, 15 Dec 2014 13:01:10 -0500 Steven Schveighoffer via Digitalmars-d-learn wrote: > > but i agree that this > > requirement should be documented. and i bet it will not, 'cause this > > will support principle of least astonishment, which is completely alien > > for D. > > Really? You done fi

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 15, 2014 at 02:27:52PM +, "Nordlöw" via Digitalmars-d-learn wrote: > Is there a combined property of AAs that combine keys and values > typically > > .pairs() > > or > > .byPairs() > > I need to sort the elements of an AA by value and then retrieved > corresponding keys in the

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/15/14 12:52 PM, ketmar via Digitalmars-d-learn wrote: On Mon, 15 Dec 2014 17:37:13 + Tobias Pankrath via Digitalmars-d-learn wrote: I think we should require byKeys and byValues to iterate the elements in the same order. Than we can just zip them for the pairwise iteration. Would th

Re: Problem calling extern(C) function

2014-12-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 December 2014 at 17:48:32 UTC, AuoroP via Digitalmars-d-learn wrote: ulong jpegSize, Without looking too closely, this sets off an alarm to me: C's long and D's long are not really compatible because C's long has variable size and D's long is 64 bit. I'd say try "import co

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread ketmar via Digitalmars-d-learn
On Mon, 15 Dec 2014 17:37:13 + Tobias Pankrath via Digitalmars-d-learn wrote: > I think we should require byKeys and byValues to iterate the > elements in the same order. Than we can just zip them for the > pairwise iteration. > > Would this impose a performance problem with the current >

Problem calling extern(C) function

2014-12-15 Thread AuoroP via Digitalmars-d-learn
I'm pretty sure my problem isn't my code but how I've built the lib. The problem is I'm calling external C code and I am getting valid data out of it but /some/ of my arguments to it is corrupted. A common thread in this newsgroup seems to be people calling Extern(Windows). I don't that is me bec

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread Tobias Pankrath via Digitalmars-d-learn
You can add an eager pairs() function to Phobos that returns an array of tuples. byPairs can't be done in object.d for the dependency from tuples that aren't yet (and perhaps never) built-in in D, and it can't be done in Phobos because it needs access to unspecified runtime functions. B

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/14/14 6:16 PM, "Nordlöw" wrote: What's the fastest way to append multiple elements to an array?: Before appending, call reserve to avoid the possibility of reallocating multiple times: arr.reserve(arr.length + n); // about to append n elements. Either arr ~= e1; arr ~= e2;

Re: Are there any methods like isDestroyed or isDisposed to detect whether some object is destroyed or not?

2014-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/13/14 2:03 AM, Andrey Derzhavin wrote: Hello! We have object, for example, objA. ObjectAType objA = new ObjectAType(...); // we have a many references to objA void someFunction1(...) { // destroying the objA destroy(one_of_the_refToObjA); // } void someFunction2(.

Re: Segmentation fault after having a certain number of elements in an array?

2014-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/15/14 10:24 AM, Steven Schveighoffer wrote: A guess -- is the class instantiated in C++? if so, it probably is not on the D heap, and probably is not scanned during GC collections. I think your m_samples array is reallocated during a collection, and you are using dangling memory. Try GC.

Re: std.bitmanip - bitshift?

2014-12-15 Thread via Digitalmars-d-learn
On Monday, 15 December 2014 at 15:19:25 UTC, Steven Schveighoffer wrote: On 12/13/14 5:47 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= " wrote: On Friday, 12 December 2014 at 19:35:26 UTC, Steven Schveighoffer wrote: On 12/12/14 2:17 PM, H. S. Teoh via Digitalmars-d-learn wrote: I've started working on a

Re: Segmentation fault after having a certain number of elements in an array?

2014-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/13/14 3:59 AM, Jeremy DeHaan wrote: I'll be trying to narrow it down even more tomorrow, but I was hoping somone here might have some insight into this weird issue I am having. I have a dynamic array of shorts that I had been trying to append to (capturing sound data). I kept getting a seg

Re: std.bitmanip - bitshift?

2014-12-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/13/14 5:47 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= " wrote: On Friday, 12 December 2014 at 19:35:26 UTC, Steven Schveighoffer wrote: On 12/12/14 2:17 PM, H. S. Teoh via Digitalmars-d-learn wrote: I've started working on an implementation of this... but it's not very clear what the correct sema

Re: Fast matrix struct

2014-12-15 Thread John Colvin via Digitalmars-d-learn
On Sunday, 14 December 2014 at 22:14:55 UTC, Ryan wrote: I'm writing a Matrix struct that I plan to use for some number crunching, which will be intensive at times. So I want it to be fast. Will I do better by manually managing the memory myself with malloc and free in the constructors/destru

Re: Asssociative Array by Key-Value-Pair

2014-12-15 Thread bearophile via Digitalmars-d-learn
Nordlöw: Is there a combined property of AAs that combine keys and values typically .pairs() or .byPairs() I need to sort the elements of an AA by value and then retrieved corresponding keys in the order sorted. You can add an eager pairs() function to Phobos that returns an array of tu

Asssociative Array by Key-Value-Pair

2014-12-15 Thread Nordlöw
Is there a combined property of AAs that combine keys and values typically .pairs() or .byPairs() I need to sort the elements of an AA by value and then retrieved corresponding keys in the order sorted.

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-15 Thread John Colvin via Digitalmars-d-learn
On Sunday, 14 December 2014 at 23:16:12 UTC, Nordlöw wrote: What's the fastest way to append multiple elements to an array?: Either arr ~= e1; arr ~= e2; arr ~= e3; or arr ~= [e1,e2,e3]; or some other trick? It does somewhat depend on context but std.array.appender is gene

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

2014-12-15 Thread drug via Digitalmars-d-learn
On 15.12.2014 12:22, "Marc Schütz" " wrote: Unfortunately you don't have access to the exception object inside the `scope(failure)` block. Ah, yes, it has to be without msg.msg scope(failure) writeln("Something is wrong");

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

2014-12-15 Thread via Digitalmars-d-learn
On Monday, 15 December 2014 at 07:41:40 UTC, drug wrote: On 13.12.2014 23:26, Suliman wrote: I reread docs and understood that scope not for such case. Next code is do what I need: try { string dbname = config.getKey("dbname"); string dbpass = config.getKey("dbpass"); string dbhost = config.get