Re: Getting familiar with std.process

2017-02-09 Thread jmh530 via Digitalmars-d-learn
On Thursday, 9 February 2017 at 21:36:46 UTC, Ali Çehreli wrote: On 02/09/2017 12:44 PM, jmh530 wrote: > I think the issue is that create_file doesn't write to stdout, it writes > to file. Correct. Pipe works by piping the standard input/output streams. > Other than reading the file and then d

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 9 February 2017 at 16:20:29 UTC, berni wrote: dmd only compiles in the files you actually pass to it. rdmd will try to find the required files automatically. Since you didn't pass the file with the function to dmd, it knows it exists, but leaves it out of the final link (it assum

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 9 February 2017 at 19:39:49 UTC, Nestor wrote: OK I changed the approach using a multidimensional array for the matrix so I could ditch arithmetic operations altogether, but curiously after measuring a few thousand runs of both implementations through avgtime, I see no noticeable

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn
Dne 9.2.2017 v 23:08 Ali Çehreli via Digitalmars-d-learn napsal(a): On 02/09/2017 02:04 PM, Nestor wrote: > I tried running each algoritm a few times through avgtime using > different digit lengths avgtime profiles the whole process, right? It measures everything that is involved in that litt

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2017 02:04 PM, Nestor wrote: > I tried running each algoritm a few times through avgtime using > different digit lengths avgtime profiles the whole process, right? It measures everything that is involved in that little program. At least OS starting the program, D runtime initializing,

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn
On Thursday, 9 February 2017 at 21:43:08 UTC, Daniel Kozak wrote: Any idea of what might be happening here? Did you try it with different backends? llvm (ldc), gcc(gdc)? Not really, just standard dmd. I tried running each algoritm a few times through avgtime using different digit lengths (up

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn
Dne 9.2.2017 v 22:29 Nestor via Digitalmars-d-learn napsal(a): On Thursday, 9 February 2017 at 20:46:06 UTC, Daniel Kozak wrote: Maybe you can try use static array instead of dynamic static immutable ubyte[10][10] QG10Matrix = ... I shaved it to this to discard unneccessary time-consuming fun

Re: Getting familiar with std.process

2017-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2017 12:44 PM, jmh530 wrote: > I think the issue is that create_file doesn't write to stdout, it writes > to file. Correct. Pipe works by piping the standard input/output streams. > Other than reading the file and then deleting it, I don't know > what else to try. create_file must wri

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn
On Thursday, 9 February 2017 at 20:46:06 UTC, Daniel Kozak wrote: Maybe you can try use static array instead of dynamic static immutable ubyte[10][10] QG10Matrix = ... I shaved it to this to discard unneccessary time-consuming functions: static immutable ubyte[10][10] QG10Matrix = [ [0,3,1

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Cym13 via Digitalmars-d-learn
On Thursday, 9 February 2017 at 19:39:49 UTC, Nestor wrote: On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote: On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote: I was trying to port C code from the article in Wikiversity [1] to D, but I'm not sure this implementation i

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn
Dne 9.2.2017 v 21:10 berni via Digitalmars-d-learn napsal(a): On Thursday, 9 February 2017 at 19:10:55 UTC, Daniel Kozak wrote: Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a): [...] Ah ok, I understand. So calling with "dmd Special/special.d Common/common.d" works. But when

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn
Dne 9.2.2017 v 20:39 Nestor via Digitalmars-d-learn napsal(a): On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote: On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote: I was trying to port C code from the article in Wikiversity [1] to D, but I'm not sure this implementati

Getting familiar with std.process

2017-02-09 Thread jmh530 via Digitalmars-d-learn
I haven't used std.process before and am trying to play around with it. In the code below, the first file writes some text to an output file. My goal is to be able to read what is written to that file without creating the file itself. I'm not sure it's possible, but the second file is my atte

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn
On Thursday, 9 February 2017 at 19:10:55 UTC, Daniel Kozak wrote: Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a): [...] Ah ok, I understand. So calling with "dmd Special/special.d Common/common.d" works. But when I compile common.d to common.o (with dmd -c common.d) and remo

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn
On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote: ... Actually since you're also multiplying by 10, you can incorporate that in the table too... I forgot to comment that what is multiplied by ten is not the value but the starting position in the array (a way to emulate a mat

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn
On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote: On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote: I was trying to port C code from the article in Wikiversity [1] to D, but I'm not sure this implementation is the most efficient way to do it in D, so suggestions to op

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn
Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a): dmd only compiles in the files you actually pass to it. rdmd will try to find the required files automatically. Since you didn't pass the file with the function to dmd, it knows it exists, but leaves it out of the final link (it as

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote: I was trying to port C code from the article in Wikiversity [1] to D, but I'm not sure this implementation is the most efficient way to do it in D, so suggestions to optimize it are welcome: import std.stdio; static immutable char[]

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Cym13 via Digitalmars-d-learn
On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote: Hi, I was trying to port C code from the article in Wikiversity [1] to D, but I'm not sure this implementation is the most efficient way to do it in D, so suggestions to optimize it are welcome: import std.stdio; static immutable

Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn
Hi, I was trying to port C code from the article in Wikiversity [1] to D, but I'm not sure this implementation is the most efficient way to do it in D, so suggestions to optimize it are welcome: import std.stdio; static immutable char[] QG10Matrix = "031759864270921548634206871359175098342

fix for sample mandelbrot code from documentation -- latest gdc has no lockingBinaryWriter

2017-02-09 Thread Oasiq via Digitalmars-d-learn
Hi, I was trying to run the example code from https://dlang.org/phobos/std_stdio.html#.File.lockingBinaryWriter which is very short, as follows. === import std.algorithm, std.range, std.stdio; void main() { enum size = 500; writef("P5\n%d %d %d\n", size, size, ubyte.max);

Re: Cross-compile with LDC

2017-02-09 Thread Joakim via Digitalmars-d-learn
On Wednesday, 8 February 2017 at 17:57:49 UTC, kinke wrote: On Wednesday, 8 February 2017 at 17:21:03 UTC, Oleg B wrote: If I understand correctly with vanilla LDC I can't cross-compiling from host linux-x86_64, but with your patch I can. Right? Right. Joakim Noah has worked on LDC for Androi

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn
dmd only compiles in the files you actually pass to it. rdmd will try to find the required files automatically. Since you didn't pass the file with the function to dmd, it knows it exists, but leaves it out of the final link (it assumes it might come from a library or something). That's why y

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread via Digitalmars-d-learn
On Thu, Feb 09, 2017 at 03:39:18PM +, berni via Digitalmars-d-learn wrote: > Now I try to run it with rdmd and dmd and get quite different results: dmd only compiles in the files you actually pass to it. rdmd will try to find the required files automatically. Since you didn't pass the file wi

Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn
I've got two source files in two directories: Common/common.d module common; import std.stdio; int main(string[] args) { Foo foo = cast(Foo)Object.factory("special.Bar"); foo.do_something(); return 0; } abstract class Foo { abstract void do_something(); } Special/special.d

Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread jkpl via Digitalmars-d-learn
On Thursday, 9 February 2017 at 15:00:21 UTC, angel wrote: On Thursday, 9 February 2017 at 14:39:41 UTC, angel wrote: On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote: I'm looking for a better way to do this, if possible: Or actually, maybe this will suite your case better: ``` templa

Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread angel via Digitalmars-d-learn
On Thursday, 9 February 2017 at 14:39:41 UTC, angel wrote: On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote: I'm looking for a better way to do this, if possible: ``` class Tool { string name; } T namedTool(alias Variable, T)() { T result = new T; result.name = Variable.str

Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread angel via Digitalmars-d-learn
On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote: I'm looking for a better way to do this, if possible: ``` class Tool { string name; } T namedTool(alias Variable, T)() { T result = new T; result.name = Variable.stringof; return result; } void main() { Tool grep;

Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread jkpl via Digitalmars-d-learn
I'm looking for a better way to do this, if possible: ``` class Tool { string name; } T namedTool(alias Variable, T)() { T result = new T; result.name = Variable.stringof; return result; } void main() { Tool grep; grep = namedTool!(grep,Tool); assert(grep.name == "gr

Re: Static array size?

2017-02-09 Thread Arek via Digitalmars-d-learn
On Thursday, 9 February 2017 at 11:22:28 UTC, Suliman wrote: Docs says that: "The total size of a static array cannot exceed 16Mb." But when I am creation array of: int [1000_000] x; // 1000_000 is equal ~ 0,95MB app crush on start. Should it's reserve this memory with guaranty? I mean that aft

Re: Static array size?

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 9 February 2017 at 12:13:36 UTC, Daniel Kozák wrote: V Thu, 09 Feb 2017 11:22:28 + Suliman via Digitalmars-d-learn napsáno: Docs says that: "The total size of a static array cannot exceed 16Mb." But when I am creation array of: int [1000_000] x; // 1000_000 is equal ~ 0,95MB

Re: Static array size?

2017-02-09 Thread jkpl via Digitalmars-d-learn
On Thursday, 9 February 2017 at 12:16:26 UTC, jkpl wrote: On Thursday, 9 February 2017 at 11:22:28 UTC, Suliman wrote: Docs says that: "The total size of a static array cannot exceed 16Mb." But when I am creation array of: int [1000_000] x; // 1000_000 is equal ~ 0,95MB app crush on start. Shou

Re: Static array size?

2017-02-09 Thread jkpl via Digitalmars-d-learn
On Thursday, 9 February 2017 at 11:22:28 UTC, Suliman wrote: Docs says that: "The total size of a static array cannot exceed 16Mb." But when I am creation array of: int [1000_000] x; // 1000_000 is equal ~ 0,95MB app crush on start. Should it's reserve this memory with guaranty? I mean that aft

Re: Static array size?

2017-02-09 Thread Daniel Kozák via Digitalmars-d-learn
V Thu, 09 Feb 2017 11:22:28 + Suliman via Digitalmars-d-learn napsáno: > Docs says that: > "The total size of a static array cannot exceed 16Mb." > But when I am creation array of: > int [1000_000] x; // 1000_000 is equal ~ 0,95MB > app crush on start. > > Should it's reserve this memory wit

Static array size?

2017-02-09 Thread Suliman via Digitalmars-d-learn
Docs says that: "The total size of a static array cannot exceed 16Mb." But when I am creation array of: int [1000_000] x; // 1000_000 is equal ~ 0,95MB app crush on start. Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager.