Re: Command Line Application in D

2014-08-04 Thread Mike James via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:03:24 UTC, TJB wrote: On Monday, 4 August 2014 at 21:58:09 UTC, maarten van damme via Digitalmars-d-learn wrote: I am a little bit confused as to what you want. There is a command line example at dlang.org, and there exists a program (rdmd) that compiles several

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
> https://github.com/D-Programming-Language/phobos/pull/1910 Very interesting discussion, thanks. I'm impressed by the amount of work you guys do on github.

Re: Command Line Application in D

2014-08-04 Thread Rikki Cattermole via Digitalmars-d-learn
On 5/08/2014 10:03 a.m., TJB wrote: On Monday, 4 August 2014 at 21:58:09 UTC, maarten van damme via Digitalmars-d-learn wrote: I am a little bit confused as to what you want. There is a command line example at dlang.org, and there exists a program (rdmd) that compiles several D files and runs th

Re: Taking from infinite forward ranges

2014-08-04 Thread Andrew Edwards via Digitalmars-d-learn
On 8/5/14, 10:28 AM, Brad Anderson wrote: On Tuesday, 5 August 2014 at 01:23:19 UTC, Andrew Edwards wrote: Is there a way to take a bounded rage from a infinite forward range? I'd use std.algorithm.until: Precisely what I was looking for. Thanks.

Re: Taking from infinite forward ranges

2014-08-04 Thread Brad Anderson via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 01:23:19 UTC, Andrew Edwards wrote: Is there a way to take a bounded rage from a infinite forward range? Given the Fibonacci sequence: auto fib = recurrence!("a[n-1] + a[n-2]")(1, 1); I can take the first n elements: take(fib, 10); But say I want

Taking from infinite forward ranges

2014-08-04 Thread Andrew Edwards via Digitalmars-d-learn
Is there a way to take a bounded rage from a infinite forward range? Given the Fibonacci sequence: auto fib = recurrence!("a[n-1] + a[n-2]")(1, 1); I can take the first n elements: take(fib, 10); But say I want all positive elements below 5 in value (there are eight such

Re: Haskell calling D code through the FFI

2014-08-04 Thread Jon via Digitalmars-d-learn
As a note, I can interact with strings as expected, but working with structs looks like it will take a little bit of work. On Monday, 4 August 2014 at 22:17:36 UTC, Jon wrote: Yes, thank you. That is exactly what I did. On Monday, 4 August 2014 at 21:48:40 UTC, safety0ff wrote: On Monday, 4

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Sean Kelly via Digitalmars-d-learn
On Monday, 4 August 2014 at 21:19:14 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Has anyone used (the fiber/taks of) vibe.d for something other than powering websites? https://github.com/D-Programming-Language/phobos/pull/1910

Re: Can't build phobos

2014-08-04 Thread Freddy via Digitalmars-d-learn
On Monday, 4 August 2014 at 10:30:40 UTC, Marc Schütz wrote: On Sunday, 3 August 2014 at 23:41:27 UTC, Freddy wrote: I am currently working on a phobos fork to include associative ranges, however the unittest fail when i try to build. How am a supposed test any unittests that i add. link:https:/

Re: Declaring run time variables

2014-08-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:18:24 UTC, splatterdash wrote: Indeed I do. I'm not sure which type I should use for the common base type, though. MyFileReader is a templated class, so using it plainly did not work. I also tried `InputRange!string` to no avail despite `MyFileReader` implementing

Re: Haskell calling D code through the FFI

2014-08-04 Thread Jon via Digitalmars-d-learn
Yes, thank you. That is exactly what I did. On Monday, 4 August 2014 at 21:48:40 UTC, safety0ff wrote: On Monday, 4 August 2014 at 21:35:21 UTC, Jon wrote: I get Error: core.runtime.rt_init is private. And Error: core.runtime.init is not accessible. I would add them to the header and Hask

Re: Declaring run time variables

2014-08-04 Thread splatterdash via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:09:49 UTC, anonymous wrote: On Monday, 4 August 2014 at 22:00:18 UTC, splatterdash wrote: ``` File f = File("input_file") // detect gzip ... if (isGzip) { auto fileIter = new MyFileReader!GzipIterator(f) } else { auto fileIter = new MyFileReader!NormalI

Re: Declaring run time variables

2014-08-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:00:18 UTC, splatterdash wrote: ``` File f = File("input_file") // detect gzip ... if (isGzip) { auto fileIter = new MyFileReader!GzipIterator(f) } else { auto fileIter = new MyFileReader!NormalIterator(f) } foreach(string line; fileIter) { // do thi

Declaring run time variables

2014-08-04 Thread splatterdash via Digitalmars-d-learn
Hello everyone, I'm trying to write a command-line application that can detect whether the input file is gzipped or not. Sounds simple enough, but I can't seem to do it properly in D (this is my first foray to the language). After checking whether the file is gzipped or not, I try to create

Re: Command Line Application in D

2014-08-04 Thread TJB via Digitalmars-d-learn
On Monday, 4 August 2014 at 21:58:09 UTC, maarten van damme via Digitalmars-d-learn wrote: I am a little bit confused as to what you want. There is a command line example at dlang.org, and there exists a program (rdmd) that compiles several D files and runs them. http://dlang.org/rdmd.html So

Re: Command Line Application in D

2014-08-04 Thread maarten van damme via Digitalmars-d-learn
I am a little bit confused as to what you want. There is a command line example at dlang.org, and there exists a program (rdmd) that compiles several D files and runs them. http://dlang.org/rdmd.html 2014-08-04 23:20 GMT+02:00 TJB via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > I

Re: Haskell calling D code through the FFI

2014-08-04 Thread safety0ff via Digitalmars-d-learn
On Monday, 4 August 2014 at 21:35:21 UTC, Jon wrote: I get Error: core.runtime.rt_init is private. And Error: core.runtime.init is not accessible. I would add them to the header and Haskell wrapper (FunctionsInD.h and ToD.hs.) The signatures are: int rt_init(); int rt_term(); When it is l

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Dicebot via Digitalmars-d-learn
On Monday, 4 August 2014 at 21:19:14 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Has anyone used (the fiber/taks of) vibe.d for something other than powering websites? Atila has implemented MQRR broker with it : https://github.com/atilaneves/mqtt It it still networking application tho

Re: Haskell calling D code through the FFI

2014-08-04 Thread Jon via Digitalmars-d-learn
I get Error: core.runtime.rt_init is private. And Error: core.runtime.init is not accessible. On Monday, 4 August 2014 at 21:22:37 UTC, safety0ff wrote: On Monday, 4 August 2014 at 21:14:17 UTC, Jon wrote: On Monday, 4 August 2014 at 21:10:46 UTC, safety0ff wrote: Don't forget to call rt_init

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 6:38 PM, Russel Winder via Digitalmars-d-learn wrote: > Are these std.concurrent threads or std.parallelism tasks? > > A std.parallelism task is not a thread. Like Erlang or Java Fork/Join > framework, the program specifies units of work and then there is a > thread pool un

Command Line Application in D

2014-08-04 Thread TJB via Digitalmars-d-learn
I am trying to build some simple command line applications that I have written in python as a way to learn D. Can you give some examples for me? For instance, I think I remember once seeing somewhere in the documentation an example that took several D files and compiled them all by running some

Re: Haskell calling D code through the FFI

2014-08-04 Thread safety0ff via Digitalmars-d-learn
On Monday, 4 August 2014 at 21:14:17 UTC, Jon wrote: On Monday, 4 August 2014 at 21:10:46 UTC, safety0ff wrote: Don't forget to call rt_init: http://dlang.org/phobos/core_runtime.html#.rt_init Where/when should I call this? Before calling any D functions, but usually it's simplest to call i

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 6:21 PM, Dicebot via Digitalmars-d-learn wrote: > vibe.d additions may help here: > > http://vibed.org/api/vibe.core.core/runTask > http://vibed.org/api/vibe.core.core/runWorkerTask > http://vibed.org/api/vibe.core.core/workerThreadCount > > "task" abstraction allows exactl

Re: Haskell calling D code through the FFI

2014-08-04 Thread Jon via Digitalmars-d-learn
On Monday, 4 August 2014 at 21:10:46 UTC, safety0ff wrote: Don't forget to call rt_init: http://dlang.org/phobos/core_runtime.html#.rt_init Where/when should I call this?

Re: Haskell calling D code through the FFI

2014-08-04 Thread safety0ff via Digitalmars-d-learn
Don't forget to call rt_init: http://dlang.org/phobos/core_runtime.html#.rt_init

Haskell calling D code through the FFI

2014-08-04 Thread Jon via Digitalmars-d-learn
TLDR -- Calling D code from Haskell through the FFI works with DMD but not with GDC or LDC2. The time consuming version: Since D allows C to directly call it, if the D code is wrapped in extern (C){ ... }, I thought it should be possible to call such D code from Haskell using the FFI. The F

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Dicebot via Digitalmars-d-learn
On Monday, 4 August 2014 at 18:22:47 UTC, Russel Winder via Digitalmars-d-learn wrote: Actually with CSP / actor model one can simply consider long-running CPU computation as form of I/O an apply same asynchronous design techniques. For example, have separate dedicated thread running the comput

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2014-08-04 at 16:57 +, Dicebot via Digitalmars-d-learn wrote: […] > This is why I had "or close" remark :) Exact number almost always > depends on exact deployment layout - i.e. what other processes > are running in the system, how hardware interrupts are handled > and so on. It is s

Re: spawnProcess command-line arguments help

2014-08-04 Thread Peter Alexander via Digitalmars-d-learn
On Sunday, 3 August 2014 at 23:48:09 UTC, Martin wrote: When I use the spawnProcess function in std.process, the command line arguments that I provide to the function seem to get "quoted". I can't reproduce this on OS X with 2.066rc1 (args are unquoted). Can someone else check Windows? Sounds

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Dicebot via Digitalmars-d-learn
On Monday, 4 August 2014 at 16:38:24 UTC, Russel Winder via Digitalmars-d-learn wrote: Modern default approach is to have amount of "worker" threads identical or close to amount of CPU cores and handle internal scheduling manually via fibers or some similar solution. I have no current data, bu

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Russel Winder via Digitalmars-d-learn
Sorry, I missed this thread (!) till now. On Mon, 2014-08-04 at 13:36 +, Dicebot via Digitalmars-d-learn wrote: > On Monday, 4 August 2014 at 05:14:22 UTC, Philippe Sigaud via > Digitalmars-d-learn wrote: > > I have another question: it seems I can spawn hundreds of > > threads > > (Heck, ev

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Dicebot via Digitalmars-d-learn
On Monday, 4 August 2014 at 14:56:36 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: On Mon, Aug 4, 2014 at 3:36 PM, Dicebot via Digitalmars-d-learn wrote: Most likely those threads either do nothing or are short living so you don't get actually 10 000 threads running simultaneously. In ge

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread via Digitalmars-d-learn
On Monday, 4 August 2014 at 14:56:36 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: On Mon, Aug 4, 2014 at 3:36 PM, Dicebot via Digitalmars-d-learn wrote: Modern default approach is to have amount of "worker" threads identical or close to amount of CPU cores and handle internal scheduling

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 3:36 PM, Dicebot via Digitalmars-d-learn wrote: > Most likely those threads either do nothing or are short living so you don't > get actually 10 000 threads running simultaneously. In general you should > expect your operating system to start stalling at few thousands of >

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Dicebot via Digitalmars-d-learn
On Monday, 4 August 2014 at 12:05:31 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: IIRC, there are fibers somewhere in core, I'll have a look. I also heard the vibe.d has them. http://dlang.org/phobos/core_thread.html#.Fiber vibe.d adds some own abstraction on top, for example "Task" c

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Dicebot via Digitalmars-d-learn
On Monday, 4 August 2014 at 05:14:22 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: I have another question: it seems I can spawn hundreds of threads (Heck, even 10_000 is accepted), even when I have 4-8 cores. Is there: is there a limit to the number of threads? I tried a threadpool becau

Re: Emacs d-mode cannot handle backquoted backslashe

2014-08-04 Thread Atila Neves via Digitalmars-d-learn
I took a look and I don't really know if it's possible without using the Emacs > 24 only suggestion in the Stack Overflow comment to your question. As far as I can see, before that Emacs syntax tables have a notion of what a string is and what an escape character is. The d-mode code adds the

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 2:13 PM, Chris Cain via Digitalmars-d-learn wrote: >> OK, I get it. Just to be sure, there is no ThreadPool in Phobos or in >> core, right? > There is. It's called taskPool, though: > > http://dlang.org/phobos/std_parallelism.html#.taskPool Ah, std.parallelism. I stoopidl

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Chris Cain via Digitalmars-d-learn
On Monday, 4 August 2014 at 12:05:31 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: OK, I get it. Just to be sure, there is no ThreadPool in Phobos or in core, right? IIRC, there are fibers somewhere in core, I'll have a look. I also heard the vibe.d has them. There is. It's called task

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
> Without going into much detail: Threads are heavy, and creating a thread is > an expensive operation (which is partially why virtually every standard > library includes a ThreadPool). > I haven't looked into detail your code, but consider using the TaskPool if > you just want to schedule some ta

Re: Can't build phobos

2014-08-04 Thread via Digitalmars-d-learn
On Sunday, 3 August 2014 at 23:41:27 UTC, Freddy wrote: I am currently working on a phobos fork to include associative ranges, however the unittest fail when i try to build. How am a supposed test any unittests that i add. link:https://github.com/Superstar64/phobos/tree/associative_ranges $ ../d

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread David Nadlinger via Digitalmars-d-learn
On Monday, 4 August 2014 at 05:14:22 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: This is correct – the LLVM optimizer indeed gets rid of the loop completely. OK,that's clever. But I get this even when put a writeln("some msg") inside the task. I thought a write couldn't be optimized aw