Re: Fibers and async io stuff for beginners

2015-04-24 Thread Chris via Digitalmars-d-learn
On Friday, 24 April 2015 at 12:38:39 UTC, Jens Bauer wrote: On Friday, 24 April 2015 at 09:15:21 UTC, Chris wrote: I was more thinking of the audio thread. But the audio is probably better off in a separate thread. I think you could do this too. In fact, this is very similar to how the

multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn
The following works great. It sorts an AA by value: 1. by frequency of word 2. by alphabetic order (if two or more words have the same value) import std.stdio : writefln; import std.algorithm.sorting : multiSort; void main() { size_t[string] wcount = [ hamster:5, zorro:80,

Re: [dvm] Can't install compilers on Mac

2015-04-29 Thread Chris via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 06:41:30 UTC, Jacob Carlborg wrote: On 2015-04-28 19:46, Chris wrote: I keep getting this message. Why? Fetching: http://ftp.digitalmars.com/dmd.2.067.0.zip [] 56256/54884 KB Installing: dmd-2.067.0 An unknown error

Re: Factory pattern in D

2015-05-01 Thread Chris via Digitalmars-d-learn
On Friday, 1 May 2015 at 10:04:46 UTC, Namespace wrote: How about this: struct A { int x = 42; } struct B { int x = 7; } T factory(T)() { return T(); } void main() { auto a = factory!(A); } That's what I was looking for, I just couldn't get it right. Thanks. Rikki: I

Factory pattern in D

2015-05-01 Thread Chris via Digitalmars-d-learn
What would be the D equivalent of the factory pattern? This obviously doesn't work: struct A { int x = 42; } struct B { int x = 7; } auto factory(string type) { if (type == A) return A(); else if (type == B) return B(); else return A(); // default } void main() {

[dvm] Can't install compilers on Mac

2015-04-28 Thread Chris via Digitalmars-d-learn
I keep getting this message. Why? Fetching: http://ftp.digitalmars.com/dmd.2.067.0.zip [] 56256/54884 KB Installing: dmd-2.067.0 An unknown error occurred: tango.core.Exception.IOException@/Users/doob/development/d/tango/tango/core/Exception.d(59):

Re: Factory pattern in D

2015-05-01 Thread Chris via Digitalmars-d-learn
On Friday, 1 May 2015 at 10:46:20 UTC, Chris wrote: On Friday, 1 May 2015 at 10:27:16 UTC, biozic wrote: On Friday, 1 May 2015 at 10:12:36 UTC, Chris wrote: On Friday, 1 May 2015 at 10:04:46 UTC, Namespace wrote: How about this: struct A { int x = 42; } struct B { int x = 7; } T

Re: Factory pattern in D

2015-05-01 Thread Chris via Digitalmars-d-learn
On Friday, 1 May 2015 at 10:27:16 UTC, biozic wrote: On Friday, 1 May 2015 at 10:12:36 UTC, Chris wrote: On Friday, 1 May 2015 at 10:04:46 UTC, Namespace wrote: How about this: struct A { int x = 42; } struct B { int x = 7; } T factory(T)() { return T(); } void main() { auto a =

Re: Factory pattern in D

2015-05-01 Thread Chris via Digitalmars-d-learn
On Friday, 1 May 2015 at 10:47:22 UTC, Chris wrote: On Friday, 1 May 2015 at 10:46:20 UTC, Chris wrote: On Friday, 1 May 2015 at 10:27:16 UTC, biozic wrote: On Friday, 1 May 2015 at 10:12:36 UTC, Chris wrote: On Friday, 1 May 2015 at 10:04:46 UTC, Namespace wrote: How about this:

Re: Factory pattern in D

2015-05-01 Thread Chris via Digitalmars-d-learn
On Friday, 1 May 2015 at 11:11:28 UTC, biozic wrote: On Friday, 1 May 2015 at 11:01:29 UTC, Chris wrote: Thinking about it, T factory(T)() { return T(); } is better suited for a factory (with static type checks). But then I don't know what factory!X() provides that X() alone doesn't.

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread Chris via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 13:32:48 UTC, Suliman wrote: By default vibed use Diet. Maybe it's cool, but for me it's easier to write in pure HTML. What is the best way to do it? You want to serve html files instead of templates, right? It should be something like router.get(*,

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread Chris via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 13:50:04 UTC, Chris wrote: On Wednesday, 6 May 2015 at 13:32:48 UTC, Suliman wrote: By default vibed use Diet. Maybe it's cool, but for me it's easier to write in pure HTML. What is the best way to do it? You want to serve html files instead of templates, right? It

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread Chris via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 14:28:26 UTC, Adam D. Ruppe wrote: On Wednesday, 6 May 2015 at 14:23:27 UTC, Chris wrote: Especially this: http://vibed.org/templates/diet#embedded-code I think that's a misfeature... if I used vibe.d, I'd want to avoid the diet too. I have never used the

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread Chris via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 14:21:24 UTC, Chris wrote: On Wednesday, 6 May 2015 at 14:07:09 UTC, Suliman wrote: I mean that I know that template can be changes dynamically, but I thought that 99% of dynamic is javascript code... Templates are like PHP, JSP, LSP etc. They can do stuff on the

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread Chris via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 14:07:09 UTC, Suliman wrote: I mean that I know that template can be changes dynamically, but I thought that 99% of dynamic is javascript code... Templates are like PHP, JSP, LSP etc. They can do stuff on the server side via embedded D code, load files for example.

Re: vibed: how to use pure HTML instead of template engine?

2015-05-07 Thread Chris via Digitalmars-d-learn
On Thursday, 7 May 2015 at 09:27:39 UTC, Chris wrote: On Thursday, 7 May 2015 at 08:25:30 UTC, Suliman wrote: You're not setting a port. add: settings.port = 8080; before listenHTTP(); then it'll work. It's do not help :( This should work, put it in your `app.d` file: import vibe.d;

Re: vibed: how to use pure HTML instead of template engine?

2015-05-07 Thread Chris via Digitalmars-d-learn
On Thursday, 7 May 2015 at 08:25:30 UTC, Suliman wrote: You're not setting a port. add: settings.port = 8080; before listenHTTP(); then it'll work. It's do not help :( This should work, put it in your `app.d` file: import vibe.d; shared static this() { auto settings = new

Re: vibed: how to use pure HTML instead of template engine?

2015-05-07 Thread Chris via Digitalmars-d-learn
Later you can have more sophisticated methods, e.g. if you want to handle query strings you could do something like this: import vibe.d; shared static this() { auto settings = new HTTPServerSettings; settings.port = 8080; settings.bindAddresses = [::1, 127.0.0.1]; auto router = new

Re: vibed: how to use pure HTML instead of template engine?

2015-05-08 Thread Chris via Digitalmars-d-learn
On Friday, 8 May 2015 at 10:20:35 UTC, Rikki Cattermole wrote: On 8/05/2015 10:17 p.m., Chris wrote: On Thursday, 7 May 2015 at 19:51:20 UTC, yawniek wrote: On Thursday, 7 May 2015 at 18:59:13 UTC, Suliman wrote: 1. Do I need write ./public/ ? In examples often simply public/ will work too.

Chaining input

2015-05-08 Thread Chris via Digitalmars-d-learn
I have the following code that converts input like blah, blub, gobble, dygook to string[] auto f = File(file.txt, r); auto words = f.byLine .map!( a = a.to!(string) .splitter(, ) .filter!(a = a.length)

Re: vibed: how to use pure HTML instead of template engine?

2015-05-08 Thread Chris via Digitalmars-d-learn
On Thursday, 7 May 2015 at 19:51:20 UTC, yawniek wrote: On Thursday, 7 May 2015 at 18:59:13 UTC, Suliman wrote: 1. Do I need write ./public/ ? In examples often simply public/ will work too. even public it goes trough Path struct, see:

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread Chris via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 18:52:41 UTC, Suliman wrote: auto html = someStringActions(); res.writeBody(cast(ubyte[])html); Thanks, but how to attach to html css file? Now page is loading, but do not handle css that also placed in this folder. CSS should be exported automatically when you

Re: Moving from Python to D

2015-05-08 Thread Chris via Digitalmars-d-learn
Moving from Python to D always a good idea ;-)

Re: Moving from Python to D

2015-05-08 Thread Chris via Digitalmars-d-learn
On Friday, 8 May 2015 at 14:13:43 UTC, Chris wrote: Moving from Python to D always a good idea ;-) You might be interested in this: http://wiki.dlang.org/Programming_in_D_for_Python_Programmers http://d.readthedocs.org/en/latest/examples.html#plotting-with-matplotlib-python

Re: Why .dup not work with multidimensional arrays?

2015-05-08 Thread Chris via Digitalmars-d-learn
On Friday, 8 May 2015 at 06:30:46 UTC, Ali Çehreli wrote: On 05/07/2015 07:39 PM, Dennis Ritchie wrote: On Friday, 8 May 2015 at 02:23:23 UTC, E.S. Quinn wrote: It's because arrays are references types, and .dup is a strictly shallow copy, so you're getting two outer arrays that reference the

Re: Chaining input

2015-05-08 Thread Chris via Digitalmars-d-learn
On Friday, 8 May 2015 at 11:14:43 UTC, Robert burner Schadek wrote: On Friday, 8 May 2015 at 11:00:01 UTC, Chris wrote: I'm sure there is room for improvement. It looks like your reading some kind of comma seperated values (csv). have a look at std.csv of phobos ``` foreach(record;

Re: Weird OSX issue

2015-05-12 Thread Chris via Digitalmars-d-learn
On Monday, 27 April 2015 at 13:54:42 UTC, Steven Schveighoffer wrote: On 4/25/15 3:07 AM, Dan Olson wrote: Jacob Carlborg d...@me.com writes: On 2015-04-24 20:37, Steven Schveighoffer wrote: So am I going crazy? Or is dmd doing things differently depending on where its environment is? Any

Re: -vgc Info ok?

2015-05-18 Thread Chris via Digitalmars-d-learn
On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote: On Mon, 18 May 2015 14:30:42 +, Chris wrote: The following string[string] myarray = [key:value]; string entry; entry = myarray[key]; // = vgc: indexing an associative array may cause GC allocation Why is _accessing_ an assoc treated

-vgc Info ok?

2015-05-18 Thread Chris via Digitalmars-d-learn
The following string[string] myarray = [key:value]; string entry; entry = myarray[key]; // = vgc: indexing an associative array may cause GC allocation Why is _accessing_ an assoc treated as indexing it?

Re: -vgc Info ok?

2015-05-19 Thread Chris via Digitalmars-d-learn
On Monday, 18 May 2015 at 18:40:15 UTC, ketmar wrote: On Mon, 18 May 2015 14:41:19 +, Chris wrote: On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote: On Mon, 18 May 2015 14:30:42 +, Chris wrote: The following string[string] myarray = [key:value]; string entry; entry =

Re: -vgc Info ok?

2015-05-19 Thread Chris via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 09:10:50 UTC, Namespace wrote: On Monday, 18 May 2015 at 14:30:43 UTC, Chris wrote: The following string[string] myarray = [key:value]; string entry; entry = myarray[key]; // = vgc: indexing an associative array may cause GC allocation Why is _accessing_ an assoc

Re: -vgc Info ok?

2015-05-19 Thread Chris via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 11:08:52 UTC, thedeemon wrote: On Monday, 18 May 2015 at 14:30:43 UTC, Chris wrote: Why is _accessing_ an assoc treated as indexing it? Are you sure you understand indexing as we do? It's not like indexing of databases, it's just accessing by index i.e. using

Re: GC: Memory keeps growing

2015-04-15 Thread Chris via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 11:48:26 UTC, Rikki Cattermole wrote: On 15/04/2015 11:44 p.m., Chris wrote: My garbage collected app starts with ~10 MB in memory, however with every execution of code it grows by at least 0.2 MB (or more depending on the input). Although I can see memory being

[dub]

2015-04-14 Thread Chris via Digitalmars-d-learn
I get the following message from dub when using --build=release: Linking... .dub/build/myprogram-release-linux.posix-x86_64-dmd_2067-C1A5273464ACE9961E3F3BA6AC04084B/abairtts.o:(.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10): undefined reference to

[dub] Release build fails with 2.067.0

2015-04-14 Thread Chris via Digitalmars-d-learn
Sorry, I forgot the title the first time around! I get the following message from dub when using --build=release: Linking...

Re: GC: Memory keeps growing

2015-04-17 Thread Chris via Digitalmars-d-learn
On Thursday, 16 April 2015 at 18:51:25 UTC, Kagamin wrote: On Wednesday, 15 April 2015 at 12:03:49 UTC, Chris wrote: There might be some low-hanging fruit there. However, before I change anything, maybe you guys have some suggestions. See if switching to 64-bit mode changes anything. 64bit

Templates: Array slices not recognized

2015-04-18 Thread Chris via Digitalmars-d-learn
The following: import std.stdio : writefln; import std.range.primitives : isInputRange, hasLength; void main() { size_t[] a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; doSomething(a); // works doSomething(a[0..5]); // --- Error: template slices.doSomething cannot deduce function from argument

Re: Templates: Array slices not recognized

2015-04-18 Thread Chris via Digitalmars-d-learn
On Saturday, 18 April 2015 at 16:26:57 UTC, Max Klyga wrote: On 2015-04-18 13:46:19 +, Chris said: The following: import std.stdio : writefln; import std.range.primitives : isInputRange, hasLength; void main() { size_t[] a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; doSomething(a); // works

Re: [dub] Release build fails with 2.067.0

2015-04-15 Thread Chris via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 10:26:55 UTC, John Colvin wrote: On Wednesday, 15 April 2015 at 10:11:17 UTC, Chris wrote: On Tuesday, 14 April 2015 at 15:58:18 UTC, Chris wrote: Sorry, I forgot the title the first time around! I get the following message from dub when using --build=release:

Re: [dub] Release build fails with 2.067.0

2015-04-15 Thread Chris via Digitalmars-d-learn
On Tuesday, 14 April 2015 at 15:58:18 UTC, Chris wrote: Sorry, I forgot the title the first time around! I get the following message from dub when using --build=release: Linking...

GC: Memory keeps growing

2015-04-15 Thread Chris via Digitalmars-d-learn
My garbage collected app starts with ~10 MB in memory, however with every execution of code it grows by at least 0.2 MB (or more depending on the input). Although I can see memory being freed (say it goes up to 32 MB and drops to 14 MB), it keeps on growing slowly but surely. I use structs

Re: -vgc Info ok?

2015-05-19 Thread Chris via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 12:41:29 UTC, ketmar wrote: On Tue, 19 May 2015 11:36:32 +, Chris wrote: On Tuesday, 19 May 2015 at 11:08:52 UTC, thedeemon wrote: On Monday, 18 May 2015 at 14:30:43 UTC, Chris wrote: Why is _accessing_ an assoc treated as indexing it? Are you sure you

AMD Windows 7

2015-06-12 Thread Chris via Digitalmars-d-learn
Has anyone run into problems with D on AMD processors? I'm talking about Windows 7 on a HP625 laptop in particular.

Re: AMD Windows 7

2015-06-12 Thread Chris via Digitalmars-d-learn
On Friday, 12 June 2015 at 14:55:15 UTC, Benjamin Thaut wrote: On Friday, 12 June 2015 at 14:39:55 UTC, Chris wrote: I wish it were an error in the Python code so I could fix it, but it works on all other machines (at least those with Intel). It's only on the HP625 with AMD that this error

Re: AMD Windows 7

2015-06-12 Thread Chris via Digitalmars-d-learn
On Friday, 12 June 2015 at 14:20:58 UTC, Alex Parrill wrote: On Friday, 12 June 2015 at 13:16:32 UTC, Chris wrote: On Friday, 12 June 2015 at 12:41:23 UTC, weaselcat wrote: On Friday, 12 June 2015 at 10:54:46 UTC, Chris wrote: Has anyone run into problems with D on AMD processors? I'm talking

Re: AMD Windows 7

2015-06-12 Thread Chris via Digitalmars-d-learn
On Friday, 12 June 2015 at 12:41:23 UTC, weaselcat wrote: On Friday, 12 June 2015 at 10:54:46 UTC, Chris wrote: Has anyone run into problems with D on AMD processors? I'm talking about Windows 7 on a HP625 laptop in particular. Can you be any more specific? What kind of problems? A DLL in D

Concurrency in DLL

2015-07-01 Thread Chris via Digitalmars-d-learn
Would anyone know off the top of the head why a std.concurrency.send() message can fail in a DLL? The DLL is loaded into Python and works (including the threading) when in a test program or mine and loaded via cytpes.CDLL() etc. However, embedded in a third party package, where it is loaded

Regex-Fu

2015-05-25 Thread Chris via Digitalmars-d-learn
I'm a bit at a loss here. I cannot get the longest possible match. I tried several versions with eager operators and stuff, but D's regex engine(s) always seem to return the shortest match. Is there something embarrassingly simple I'm missing? void main() { import std.regex : regex,

Re: Regex-Fu

2015-05-25 Thread Chris via Digitalmars-d-learn
On Monday, 25 May 2015 at 11:20:46 UTC, novice2 wrote: I cannot get the longest possible it match longest for first group ([a-z]+) try ^([a-z]+?)(hula|ula)$ Namespace, novice2: Ah, I see. The problem was with the first group that was too greedy, not with the second. I was focusing on the

Re: flush MessageBox

2015-08-21 Thread Chris via Digitalmars-d-learn
On Thursday, 20 August 2015 at 15:57:47 UTC, John Colvin wrote: On Thursday, 20 August 2015 at 15:25:57 UTC, Chris wrote: Is there a way to flush a thread's message box other than aborting the thread? MailBox is private:

Re: flush MessageBox

2015-08-21 Thread Chris via Digitalmars-d-learn
On Friday, 21 August 2015 at 12:59:09 UTC, John Colvin wrote: On Friday, 21 August 2015 at 10:43:22 UTC, Chris wrote: On Thursday, 20 August 2015 at 15:57:47 UTC, John Colvin wrote: On Thursday, 20 August 2015 at 15:25:57 UTC, Chris wrote: Is there a way to flush a thread's message box other

Re: flush MessageBox

2015-08-21 Thread Chris via Digitalmars-d-learn
On Friday, 21 August 2015 at 14:35:53 UTC, Chris wrote: On Friday, 21 August 2015 at 12:59:09 UTC, John Colvin wrote: On Friday, 21 August 2015 at 10:43:22 UTC, Chris wrote: On Thursday, 20 August 2015 at 15:57:47 UTC, John Colvin wrote: On Thursday, 20 August 2015 at 15:25:57 UTC, Chris

Re: flush MessageBox

2015-08-24 Thread Chris via Digitalmars-d-learn
On Friday, 21 August 2015 at 17:05:56 UTC, John Colvin wrote: On Friday, 21 August 2015 at 14:35:53 UTC, Chris wrote: On Friday, 21 August 2015 at 12:59:09 UTC, John Colvin wrote: [...] Wouldn't it be easier to have a library function that can empty the mailbox immediately? It's a waste of

flush MessageBox

2015-08-20 Thread Chris via Digitalmars-d-learn
Is there a way to flush a thread's message box other than aborting the thread? MailBox is private: https://github.com/D-Programming-Language/phobos/blob/master/std/concurrency.d#L1778

Struct vs. Class

2015-06-26 Thread Chris via Digitalmars-d-learn
I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in general turn out to be a nuisance. It's not so hard to turn the classes into structs, a lot of classes are in fact singletons (yes, I've been kinda fading out classes for a

Re: Struct vs. Class

2015-06-26 Thread Chris via Digitalmars-d-learn
On Friday, 26 June 2015 at 11:28:38 UTC, Daniel Kozák wrote: On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP

Re: Yes or No Options

2015-07-29 Thread Chris via Digitalmars-d-learn
On Monday, 27 July 2015 at 15:50:11 UTC, Alex wrote: Hey guys! I am super new to programming and still trying to learn the very basics via a book that I bought. Out of interest: what made you start with D? It's not the most obvious choice for a programming novice.

Re: Yes or No Options

2015-07-30 Thread Chris via Digitalmars-d-learn
On Thursday, 30 July 2015 at 14:20:41 UTC, Alex wrote: My father owns a small software company, specialized in market data products. www.bccgi.com (in case anyone is interested) So programming was basically around all my life. I do a small job in his company and my next task was to learn D.

Thread communication

2015-08-04 Thread Chris via Digitalmars-d-learn
Is there a good way to stop work-intensive threads via thread communication (instead of using a shared variable)? The example below is very basic and naive and only meant to exemplify the basic problem. I want to stop (and abort) the worker as soon as new input arrives. However, while

Re: Thread communication

2015-08-05 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 18:15:08 UTC, Ali Çehreli wrote: On 08/04/2015 09:19 AM, Dicebot wrote: receiveTimeout I think the problem here is that the worker is busy, not even able to call that. This sounds like sending a signal to the specific thread (with pthread_kill()) but I don't

Re: Yes or No Options

2015-07-31 Thread Chris via Digitalmars-d-learn
On Thursday, 30 July 2015 at 17:48:51 UTC, Ali Çehreli wrote: On 07/30/2015 08:14 AM, Chris wrote: I wonder, is your father's company listed among those using D? I think there's a list somewhere on Wiki, if not we should have one :-) I don't think they use D yet but the page is here:

Re: Thread communication

2015-08-06 Thread Chris via Digitalmars-d-learn
On Thursday, 6 August 2015 at 08:40:58 UTC, Kagamin wrote: } AFAIK, boost does it by integrating support for interruption into various functions, so IO, waits and locks reply to interrupt requests appropriately. You can do something similar. I understand the philosophy behind

std.stream.MemoryStream deprecated, range is the alternative?

2015-08-06 Thread chris via Digitalmars-d-learn
class Test { MemoryStream m_stream; this(MemoryStream stream) { m_stream = stream; } void write(byte val) { m_stream.write(val); } byte read() { byte val; m_stream.read(val); return val; } } void main() { byte[] read =

Re: Concurrency Confusion

2015-08-07 Thread Chris via Digitalmars-d-learn
On Thursday, 6 August 2015 at 21:17:15 UTC, 岩倉 澪 wrote: On Tuesday, 4 August 2015 at 08:35:10 UTC, Dicebot wrote: // in real app use `receiveTimeout` to do useful stuff until // result message is received auto output = receiveOnly!(immutable(Bar)[]); New question: how would I

Re: Concurrency Confusion

2015-08-07 Thread Chris via Digitalmars-d-learn
On Friday, 7 August 2015 at 15:55:33 UTC, Chris wrote: Using a shared boolean is probably not the best way, I should have said the most efficient and reliable way.

Re: Concurrency Confusion

2015-08-08 Thread Chris via Digitalmars-d-learn
On Saturday, 8 August 2015 at 00:39:57 UTC, 岩倉 澪 wrote: On Friday, 7 August 2015 at 22:13:35 UTC, 岩倉 澪 wrote: message is local to the delegate that receiveTimeout takes. I want to use message outside of the delegate in the receiving thread. However, if you send an immutable value from the

Re: Thread pools

2015-07-22 Thread Chris via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 15:41:06 UTC, Alex Parrill wrote: On Wednesday, 22 July 2015 at 14:28:48 UTC, Chris wrote: What would be the best way to manage different threads (spawned via std.concurrency), e.g. to tell them to stop at once, once a new command comes in? A thread pool? How

Re: Thread pools

2015-07-23 Thread Chris via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 17:01:52 UTC, Marc Schütz wrote: You can probably simply terminate the main thread, which will send an OwnerTerminated message to all dependent threads. The threads need to `receive()` this message and terminate. Not possible here. Main has to run the all the

Re: Thread pools

2015-07-23 Thread Chris via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 16:16:36 UTC, John Colvin wrote: I would send a message to terminate to thread1, which would in turn send a similar message to any threads it has started, wait until they've all stopped (maybe with a time-out), then return. I.e. every thread knows how to

Thread pools

2015-07-22 Thread Chris via Digitalmars-d-learn
What would be the best way to manage different threads (spawned via std.concurrency), e.g. to tell them to stop at once, once a new command comes in? A thread pool? How would that look like in D? I feel my knowledge of D threads is still a bit limited.

Re: Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
On Monday, 16 November 2015 at 16:49:19 UTC, Marc Schütz wrote: On Monday, 16 November 2015 at 16:44:27 UTC, Chris wrote: Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or

Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or use .tupleof for code like foreach (ref it; myArray.doSomething) {} Probably not the best idea anyway. What's the best

Re: Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
On Monday, 16 November 2015 at 17:57:53 UTC, opla wrote: On Monday, 16 November 2015 at 16:55:29 UTC, Chris wrote: On Monday, 16 November 2015 at 16:49:19 UTC, Marc Schütz wrote: On Monday, 16 November 2015 at 16:44:27 UTC, Chris wrote: Updating my code from 2.067.1 to 2.069.1 (I skipped

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 11:58:22 UTC, Chris wrote: Sorry that should be: @property void popFront() { r = r[1..$]; cnt++; }

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
I've checked several options now and it doesn't work. Here (http://dlang.org/statement.html#foreach-with-ranges) it is stated that it suffices to have range primitives, if opApply doesn't exist. My code worked up to 2.068.0, with the introduction of 2.068.1 it failed. I wonder why that is.

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote: Ok, that's a strange implementation of opIndex(). Usually, a parameter-less opIndex() is supposed to return a slice into the full range, but yours returns a size_t, which of course can't be iterated over. The change that made

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 11:26:19 UTC, Marc Schütz wrote: That really depends on the details, that's why I asked. It could be a regression, or it could be that the compiler now does stricter checking than before, and your implementation wasn't completely correct, or it could be a bug

Re: bearophile is back! :) was: Re: conver BigInt to string

2015-11-05 Thread Chris via Digitalmars-d-learn
On Thursday, 5 November 2015 at 19:38:23 UTC, Ali Çehreli wrote: Good one! ;) I'm really happy that he is still around. Ali So am I! The more, the merrier!

Re: bearophile is back! :) was: Re: conver BigInt to string

2015-11-05 Thread Chris via Digitalmars-d-learn
On Thursday, 5 November 2015 at 19:30:02 UTC, Ali Çehreli wrote: On 11/05/2015 09:40 AM, bearophile wrote: Bye, bearophile Were you immersed in another language? Rust? Ali His D doesn't seem to be Rusty though!

Re: good reasons not to use D?

2015-11-03 Thread Chris via Digitalmars-d-learn
On Friday, 30 October 2015 at 10:35:03 UTC, Laeeth Isharc wrote: Interesting. Two points suggest that you should use D only for serious programming: "cases where you want to write quick one-off scripts that need to use a bunch of different libraries not yet available in D and where it

Re: OT: why do people use python when it is slow?

2015-10-15 Thread Chris via Digitalmars-d-learn
On Thursday, 15 October 2015 at 09:47:56 UTC, Ola Fosheim Grøstad wrote: On Thursday, 15 October 2015 at 09:24:52 UTC, Chris wrote: Yep. This occurred to me too. Sorry Ola, but I think you don't know how sausages are made. I most certainly do. I am both doing backend programming and we have

Re: OT: why do people use python when it is slow?

2015-10-15 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 18:17:29 UTC, Russel Winder wrote: The thing about Python is NumPy, SciPy, Pandas, Matplotlib, IPython, Jupyter, GNU Radio. The data science, bioinformatics, quant, signal provessing, etc. people do not give a sh!t which language they used, what they want

Re: OT: why do people use python when it is slow?

2015-10-15 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 18:37:40 UTC, Mengu wrote: On Wednesday, 14 October 2015 at 05:42:12 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc wrote: https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow Andrei suggested posting

Re: LuaD: creating a flexible data filter system

2015-10-16 Thread Chris via Digitalmars-d-learn
On Friday, 16 October 2015 at 09:01:57 UTC, yawniek wrote: hi, i'm reading in a stream of data that is deserialized into individual frames. a frame is either of: a) a specific D datastructure ( struct with a few ulong,string,string[string] etc members), known at compile time b) json

Re: LuaD: creating a flexible data filter system

2015-10-17 Thread Chris via Digitalmars-d-learn
On Saturday, 17 October 2015 at 02:02:16 UTC, Jakob Ovrum wrote: On Friday, 16 October 2015 at 10:45:52 UTC, Chris wrote: Later you call the function with the Lua C API like "lua_pcall(L, 0, 1, 0);". It's a bit tricky to move things around on the Lua stack, but you'll get there! ;) Or you

Re: Lazy sort

2015-09-11 Thread Chris via Digitalmars-d-learn
On Friday, 11 September 2015 at 10:41:16 UTC, ixid wrote: Does sort have to be eager or would it be possible to have a lazy version? It's messy to always have to use array and leap in and out of lazy operations within a UFCS chain. Surely as many functions as possible should be optionally

Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
If I have code like this: auto builder = appender!string; builder ~= "Hello, World!"; builder ~= "I'm here!"; builder ~= "Now I'm there!"; the object file grows by 10-11 lines with each call to `builder ~=`. If I use this: builder ~= format("%s", "Hello, World!"); builder ~= format("%s",

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your original code was quite small?). It was in a test program. Only a few lines. But it would still add a lot of bloat in a

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 15:17:21 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 13:42:15 UTC, Chris wrote: On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: [...] Thanks. That's up to date enough now. Is it stable, though? Reasonably so in my testing,

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 10:53:17 UTC, Chris wrote: On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your

Linker error with dmd

2015-10-02 Thread Chris via Digitalmars-d-learn
Why do I get this error msg with dmd 2.067.1 and 2.068.0 in release mode: $ dub --build=release (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10): undefined reference to `_D64TypeInfo_C3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ'

What's wrong with this code?

2015-09-18 Thread Chris via Digitalmars-d-learn
This crashes when triggered: voxel_vec [string] move_buttons = [ "button_xp" : voxel_vec ([ 1, 0, 0 ]), "button_xm" : voxel_vec ([ -1, 0, 0 ]), "button_yp" : voxel_vec ([ 0, 1, 0 ]),

Re: What's wrong with this code?

2015-09-19 Thread Chris via Digitalmars-d-learn
On Saturday, 19 September 2015 at 02:45:54 UTC, Adam D. Ruppe wrote: On Saturday, 19 September 2015 at 02:30:39 UTC, Chris wrote: bmove.addOnClicked (delegate void (Button aux) { What's the context of this call? If it is inside a struct and you are accessing local

Re: What's wrong with this code?

2015-09-19 Thread Chris via Digitalmars-d-learn
Update: If I add *also* a auto vec2 = vec; now the code works. So it looks like this now: voxel_vec [string] move_buttons = [ "button_xp" : voxel_vec ([ 1, 0, 0 ]), "button_xm" : voxel_vec ([ -1, 0, 0 ]),

Re: Linker error with dmd

2015-10-06 Thread Chris via Digitalmars-d-learn
On Friday, 2 October 2015 at 14:03:08 UTC, John Colvin wrote: On Friday, 2 October 2015 at 09:43:54 UTC, Chris wrote: Why do I get this error msg with dmd 2.067.1 and 2.068.0 in release mode: $ dub --build=release

What's wrong with my debugger?

2015-12-23 Thread Chris via Digitalmars-d-learn
Please see the linked screenshot: http://i.imgur.com/SpkXu5m.png As you can see, the inside, outside and collision arrays don't seem to work with the debugger. They show a bogus lenght and a bogus memory address. Extracting the lenghts to separate variables outl, insl and coll show that the

Re: What's wrong with my debugger?

2015-12-24 Thread Chris via Digitalmars-d-learn
On Thursday, 24 December 2015 at 09:30:24 UTC, Rainer Schuetze wrote: In the locals window, mago displays all instances of variables, but with the same value (which might be some uninitialized value of a different declaration than expected). The Visual Studio debug engine shows different

Re: Linker error

2016-06-10 Thread Chris via Digitalmars-d-learn
On Friday, 10 June 2016 at 12:12:17 UTC, ketmar wrote: On Friday, 10 June 2016 at 12:04:50 UTC, Chris wrote: I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the

Linker error

2016-06-10 Thread Chris via Digitalmars-d-learn
I get the error below with code like this: auto res = ['1', '2'].map!(a => a.to!string); dmd 2.071.0 What's wrong here? I import std.algorithm, std.range, std.array, std.conv in the module. (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10):

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 14:32:11 UTC, ag0aep6g wrote: On 05/25/2016 03:27 PM, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? popFront doesn't make sense with a tuple

<    1   2   3   >