Re: DerelictFmodStudio not found...

2017-02-10 Thread rikki cattermole via Digitalmars-d-learn
On 11/02/2017 5:38 PM, WhatMeWorry wrote: On Saturday, 11 February 2017 at 03:10:35 UTC, WhatMeWorry wrote: I followed the instructions for derelict.fmod. // Load the Fmod library. DerelictFmod.load(); // compiles fine. // Load the Fmod studio library. DerelictFmodStudio.load(); but

Re: Mallocator and 'shared'

2017-02-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 10 February 2017 at 23:57:18 UTC, bitwise wrote: https://github.com/dlang/phobos/blob/cd7846eb96ea7d2fa65ccb04b4ca5d5b0d1d4a63/std/experimental/allocator/mallocator.d#L63-L65 Looking at Mallocator, the use of 'shared' doesn't seem correct to me. [...] IIRC you're supposed to use

Re: DerelictFmodStudio not found...

2017-02-10 Thread WhatMeWorry via Digitalmars-d-learn
On Saturday, 11 February 2017 at 03:10:35 UTC, WhatMeWorry wrote: I followed the instructions for derelict.fmod. // Load the Fmod library. DerelictFmod.load(); // compiles fine. // Load the Fmod studio library. DerelictFmodStudio.load(); but the Studio load

Re: Mallocator and 'shared'

2017-02-10 Thread Michael Coulombe via Digitalmars-d-learn
On Friday, 10 February 2017 at 23:57:18 UTC, bitwise wrote: https://github.com/dlang/phobos/blob/cd7846eb96ea7d2fa65ccb04b4ca5d5b0d1d4a63/std/experimental/allocator/mallocator.d#L63-L65 Looking at Mallocator, the use of 'shared' doesn't seem correct to me. The logic stated in the comment

Gc collects trigger access violation exception

2017-02-10 Thread mashomee via Digitalmars-d-learn
Hi, everyone. I have a thread running in Dll. But it always halts because of access violation exception when GC begins collecting. This is the thread stack frame in vs2013. testSendSms.exe!_D4core6thread6Thread9isRunningMFNbNdZb() + 0x1 bytes D

DerelictFmodStudio not found...

2017-02-10 Thread WhatMeWorry via Digitalmars-d-learn
I followed the instructions for derelict.fmod. // Load the Fmod library. DerelictFmod.load(); // compiles fine. // Load the Fmod studio library. DerelictFmodStudio.load(); but the Studio load ..\common\derelict_libraries.d(122,5): Error: undefined identifier 'DerelictFmodStudio' In

Re: Why do static arrays affect executable size?

2017-02-10 Thread sarn via Digitalmars-d-learn
On Friday, 10 February 2017 at 15:12:28 UTC, Jonathan M Davis wrote: Module-level and static variables all get put in the executable. So, declaring a static array like that is going to take up space. A dynamic array would do the same thing if you gave it a value of that size. The same thing

Mallocator and 'shared'

2017-02-10 Thread bitwise via Digitalmars-d-learn
https://github.com/dlang/phobos/blob/cd7846eb96ea7d2fa65ccb04b4ca5d5b0d1d4a63/std/experimental/allocator/mallocator.d#L63-L65 Looking at Mallocator, the use of 'shared' doesn't seem correct to me. The logic stated in the comment above is that 'malloc' is thread safe, and therefore all

Re: Why is for() less efficient than foreach?

2017-02-10 Thread Dukc via Digitalmars-d-learn
On Friday, 10 February 2017 at 13:33:55 UTC, Bastiaan Veelo wrote: Thanks, I should have spotted that. Bastiaan. No, you don't even have to spot things like that. If you assert() the result that is. (Not a rant, half of us wouldn't probably have bothered).

Re: std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
10.02.2017 19:31, Jonathan M Davis via Digitalmars-d-learn пишет: On Friday, February 10, 2017 19:06:53 drug via Digitalmars-d-learn wrote: 10.02.2017 18:02, Jonathan M Davis via Digitalmars-d-learn пишет: On Friday, February 10, 2017 14:35:28 drug via Digitalmars-d-learn wrote: I found

Re: std.datetime

2017-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 10, 2017 19:06:53 drug via Digitalmars-d-learn wrote: > 10.02.2017 18:02, Jonathan M Davis via Digitalmars-d-learn пишет: > > On Friday, February 10, 2017 14:35:28 drug via Digitalmars-d-learn wrote: > >> I found error - years should start from 1, not 0. > >> But if months or

Re: std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
10.02.2017 18:02, Jonathan M Davis via Digitalmars-d-learn пишет: On Friday, February 10, 2017 14:35:28 drug via Digitalmars-d-learn wrote: I found error - years should start from 1, not 0. But if months or days start from 0 std.datetime throws exception and don't for years - it isn't clear

Re: Why do static arrays affect executable size?

2017-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 10, 2017 11:21:48 Bastiaan Veelo via Digitalmars-d-learn wrote: > // enum int maxarray = 0; > enum int maxarray = 2_000_000; > > double[maxarray] a, b, c, d; > > void main() {} > > > Compiled using "dub build --arch=x86_64 --build=release" on > Windows (DMD32 D Compiler

Re: std.datetime

2017-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 10, 2017 14:35:28 drug via Digitalmars-d-learn wrote: > I found error - years should start from 1, not 0. > But if months or days start from 0 std.datetime throws exception and > don't for years - it isn't clear that zero year is negative one (in that > mean that stdTime for

Re: Why is for() less efficient than foreach?

2017-02-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 10 February 2017 at 12:58:19 UTC, Stefan Koch wrote: If you want it to modify the array you have to use a ref elem. If you do you will see that foreach is a little slower. Thanks, I should have spotted that. Bastiaan.

Re: Why is for() less efficient than foreach?

2017-02-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 10 February 2017 at 12:57:38 UTC, biozic wrote: On Friday, 10 February 2017 at 12:39:50 UTC, Bastiaan Veelo wrote: void foreach_loop() { foreach(n, elem; d[]) elem = a[n] * b[n] / c[n]; } It's fast because the result of the operation (elem) is

Re: Why is for() less efficient than foreach?

2017-02-10 Thread evilrat via Digitalmars-d-learn
On Friday, 10 February 2017 at 13:13:24 UTC, evilrat wrote: On my machine (AMD FX-8350) actually almost no difference oops, it skips flags with -run -_- sorry dmd loops.d -release Function 0 took: 16 ╬╝s and 5 hnsecs Function 1 took: 55 secs, 262 ms, 844 ╬╝s, and 6 hnsecs Function 2 took:

Re: Why is for() less efficient than foreach?

2017-02-10 Thread evilrat via Digitalmars-d-learn
On Friday, 10 February 2017 at 12:39:50 UTC, Bastiaan Veelo wrote: Depending on the machine this is run on, for() performs a factor 3-8 slower than foreach(). Can someone explain this to me? Or, taking for() as the norm, how can foreach() be so blazingly fast? Thanks! On my machine (AMD

Re: Why is for() less efficient than foreach?

2017-02-10 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 10 February 2017 at 12:39:50 UTC, Bastiaan Veelo wrote: Benchmarking for() against foreach(): / enum size_t maxarray = 500_000; double[maxarray] a, b, c, d; void main() { import std.stdio; import std.datetime; import std.random; for (int n = 0; n <

Re: Why is for() less efficient than foreach?

2017-02-10 Thread biozic via Digitalmars-d-learn
On Friday, 10 February 2017 at 12:39:50 UTC, Bastiaan Veelo wrote: void foreach_loop() { foreach(n, elem; d[]) elem = a[n] * b[n] / c[n]; } It's fast because the result of the operation (elem) is discarded on each iteration, so it is probably optimized away.

Why is for() less efficient than foreach?

2017-02-10 Thread Bastiaan Veelo via Digitalmars-d-learn
Benchmarking for() against foreach(): / enum size_t maxarray = 500_000; double[maxarray] a, b, c, d; void main() { import std.stdio; import std.datetime; import std.random; for (int n = 0; n < maxarray; n++) { a[n] = uniform01; b[n] = uniform01;

Re: std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
10.02.2017 14:15, drug пишет: unittest { import std.datetime : SysTime, UTC; { auto st = SysTime(); st.timezone(UTC()); long date = st.fromISOExtString("2017-02-10T00:00:00Z").stdTime, time_of_day =

Re: Can this implementation of Damm algorithm be optimized?

2017-02-10 Thread Nestor via Digitalmars-d-learn
On Thursday, 9 February 2017 at 23:49:19 UTC, Era Scarecrow wrote: Other optimizations could be to make it multiple levels, taking the basic 100 elements and expanding them 2-3 levels deep in a lookup and having it do it in more or less a single operation. (100 bytes for 1 level, 10,000 for 2

Re: Why do static arrays affect executable size?

2017-02-10 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 10 February 2017 at 11:21:48 UTC, Bastiaan Veelo wrote: // enum int maxarray = 0; enum int maxarray = 2_000_000; double[maxarray] a, b, c, d; void main() {} Compiled using "dub build --arch=x86_64 --build=release" on Windows (DMD32 D Compiler v2.073.0), the exe size is 302_592

Why do static arrays affect executable size?

2017-02-10 Thread Bastiaan Veelo via Digitalmars-d-learn
// enum int maxarray = 0; enum int maxarray = 2_000_000; double[maxarray] a, b, c, d; void main() {} Compiled using "dub build --arch=x86_64 --build=release" on Windows (DMD32 D Compiler v2.073.0), the exe size is 302_592 bytes v.s. 64_302_592 bytes, depending on the array length. Is that

std.datetime

2017-02-10 Thread drug via Digitalmars-d-learn
unittest { import std.datetime : SysTime, UTC; { auto st = SysTime(); st.timezone(UTC()); long date = st.fromISOExtString("2017-02-10T00:00:00Z").stdTime, time_of_day =

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread berni via Digitalmars-d-learn
On Friday, 10 February 2017 at 09:34:39 UTC, berni wrote: On Friday, 10 February 2017 at 09:25:04 UTC, Daniel Kozak wrote: Now I tried this with a named instead of a magic constant e.g. immutable VALUE=-1; arr.each!"a[]=VALUE"; And it doesn't work anymore. I've no clue, why... Can you help

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread berni via Digitalmars-d-learn
On Friday, 10 February 2017 at 09:25:04 UTC, Daniel Kozak wrote: Now I tried this with a named instead of a magic constant e.g. immutable VALUE=-1; arr.each!"a[]=VALUE"; And it doesn't work anymore. I've no clue, why... Can you help me? Because it does not see VALUE, you need to use

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 February 2017 at 09:03:16 UTC, berni wrote: Now I tried this with a named instead of a magic constant e.g. immutable VALUE=-1; arr.each!"a[]=VALUE"; And it doesn't work anymore. I've no clue, why... Can you help me? each is a template. As per the template documentation

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread Daniel Kozak via Digitalmars-d-learn
Dne 10.2.2017 v 10:03 berni via Digitalmars-d-learn napsal(a): On Tuesday, 7 February 2017 at 19:06:22 UTC, berni wrote: auto arr = uninitializedArray!(int[][])(ROWS,COLS); arr.each!"a[]=-1"; This looks like what I was looking for. At least I think I understand what's going on here. The

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread berni via Digitalmars-d-learn
On Tuesday, 7 February 2017 at 19:06:22 UTC, berni wrote: auto arr = uninitializedArray!(int[][])(ROWS,COLS); arr.each!"a[]=-1"; This looks like what I was looking for. At least I think I understand what's going on here. The other two suggestions are beyond my scope yet, but I'll come back,

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

2017-02-10 Thread berni via Digitalmars-d-learn
$> dmd Special/special.d Common/common.o Special/special.d(4): Error: module common is in file 'common.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import This is not a linker error. It's a compiler error. You need common.d for