Re: html fetcher/parser

2017-08-13 Thread Faux Amis via Digitalmars-d-learn
On 2017-08-13 01:49, Soulsbane wrote: On Saturday, 12 August 2017 at 19:53:22 UTC, Faux Amis wrote: I would like to get into D again by making a small program which fetches a website every X-time and keeps track of all changes within specified dom elements. fetching: should I go for std

Re: Unresolved external symbol InterlockedIncrement

2017-08-13 Thread Igor via Digitalmars-d-learn
On Sunday, 13 August 2017 at 16:29:14 UTC, Igor wrote: I am building a 64 bit windows app with latest DMD and I keep getting this linker error: error LNK2019: unresolved external symbol InterlockedIncrement referenced in function ThreadProc This function should be a part of kernel32.lib

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:56:44 UTC, Johan Engelen wrote: On Sunday, 13 August 2017 at 09:15:48 UTC, amfvcg wrote: Change the parameter for this array size to be taken from stdin and I assume that these optimizations will go away. This is paramount for all of the testing, examining,

Unresolved external symbol InterlockedIncrement

2017-08-13 Thread Igor via Digitalmars-d-learn
I am building a 64 bit windows app with latest DMD and I keep getting this linker error: error LNK2019: unresolved external symbol InterlockedIncrement referenced in function ThreadProc This function should be a part of kernel32.lib which I verified is found by using /VERBOSE:LIB linker

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-13 Thread Arek via Digitalmars-d-learn
On Sunday, 13 August 2017 at 02:50:13 UTC, crimaniak wrote: On Saturday, 12 August 2017 at 18:57:44 UTC, Arek wrote: I have the folowing problem: I like to envelope the class object in struct to control the destruction moment and then send this object to another thread/fiber (or task, cause I

Read/Write memory barriers in D?

2017-08-13 Thread Igor via Digitalmars-d-learn
I am converting a C code that uses this macro: #define CompletePastWritesBeforeFutureWrites _WriteBarrier(); _mm_sfence() As far as I see core.atomic:atomicFence() is the equivalent of _mm_sfence() but I can't find what would be the equivalent of _WriteBarrier(). As far as I understand it

Re: Read/Write memory barriers in D?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
or maybe use core.atomic.atomicLoad and store with right https://dlang.org/phobos/core_atomic.html#.MemoryOrder On Sun, Aug 13, 2017 at 1:51 PM, Daniel Kozak wrote: > maybe something like https://dlang.org/phobos/ > core_bitop.html#.volatileLoad and https://dlang.org/phobos/

Re: html fetcher/parser

2017-08-13 Thread Faux Amis via Digitalmars-d-learn
On 2017-08-12 22:22, Adam D. Ruppe wrote: On Saturday, 12 August 2017 at 19:53:22 UTC, Faux Amis wrote: [...] [...] --- // compile: $ dmd thisfile.d ~/arsd/{dom,http2,characterencodings} import std.stdio; import arsd.dom; void main() { auto document =

Re: Read/Write memory barriers in D?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
maybe something like https://dlang.org/phobos/core_bitop.html#.volatileLoad and https://dlang.org/phobos/core_bitop.html#.volatileStore On Sun, Aug 13, 2017 at 1:37 PM, Igor via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I am converting a C code that uses this macro: > >

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Neia Neutuladh via Digitalmars-d-learn
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote: Hi all, I'm solving below task: Well, for one thing, you are preallocating in C++ code but not in D. On my machine, your version of the code completes in 3.175 seconds. Changing it a little reduces it to 0.420s: T[] result =

D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
Hi all, I'm solving below task: given container T and value R return sum of R-ranges over T. An example: input : T=[1,1,1] R=2 output : [2, 1] input : T=[1,2,3] R=1 output : [1,2,3] (see dlang unittests for more examples) Below c++ code compiled with g++-5.4.0 -O2 -std=c++14 runs on my

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread rikki cattermole via Digitalmars-d-learn
On 13/08/2017 7:09 AM, amfvcg wrote: Hi all, I'm solving below task: given container T and value R return sum of R-ranges over T. An example: input : T=[1,1,1] R=2 output : [2, 1] input : T=[1,2,3] R=1 output : [1,2,3] (see dlang unittests for more examples) Below c++ code compiled with

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Roman Hargrave via Digitalmars-d-learn
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote: Hi all, I'm solving below task: given container T and value R return sum of R-ranges over T. An example: input : T=[1,1,1] R=2 output : [2, 1] input : T=[1,2,3] R=1 output : [1,2,3] (see dlang unittests for more examples) Below c++

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
this works ok for me with ldc compiler, gdc does not work on my arch machine so I can not do comparsion to your c++ versin (clang does not work with your c++ code) import std.stdio : writeln; import std.algorithm.comparison: min; import std.algorithm.iteration: sum; import core.time: MonoTime,

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
Here is more D idiomatic way: import std.stdio : writeln; import std.algorithm.comparison: min; import std.algorithm.iteration: sum; import core.time: MonoTime, Duration; auto sum_subranges(T)(T input, uint range) { import std.array : array; import std.range : chunks, ElementType;

Launch and obtain thread output during compile time

2017-08-13 Thread data pulverizer via Digitalmars-d-learn
Hi all, Is it possible to launch/spawn a thread/fibre or some other appropriate item and obtain an immutable/enum or some appropriate output at compile-time? For instance return an immutable(string) from the external thread to be used as the input to a template parameter or a CTFE function.

Real naive template question

2017-08-13 Thread WhatMeForget via Digitalmars-d-learn
module block_template; void main() { template BluePrint(T, U) { T integer; U floatingPoint; } BluePrint!(int, float); } // DMD returns // template.d(13): Error: BluePrint!(int, float) has no effect // I was expecting something like the following to be created

Re: Real naive template question

2017-08-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 14 August 2017 at 00:44:05 UTC, WhatMeForget wrote: module block_template; void main() { template BluePrint(T, U) { T integer; U floatingPoint; } BluePrint!(int, float); } // DMD returns // template.d(13): Error: BluePrint!(int, float) has no effect

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: pretty simply, trying to convert a floating point to a string in a ctfe function and it thinks that it is too complex to do in a ctfe, really? It uses a C function to do the conversion, which is not available at compile time

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread HypperParrow via Digitalmars-d-learn
On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: Error: uncaught CTFE exception std.format.FormatException("Cannot format floating point types at compile-time") called from here: to(0.75) pretty simply, trying to convert a floating point to a string in a ctfe function and it

wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Johnson Jones via Digitalmars-d-learn
Error: uncaught CTFE exception std.format.FormatException("Cannot format floating point types at compile-time") called from here: to(0.75) pretty simply, trying to convert a floating point to a string in a ctfe function and it thinks that it is too complex to do in a ctfe, really?

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Johnson via Digitalmars-d-learn
On Monday, 14 August 2017 at 03:52:40 UTC, HypperParrow wrote: On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: Error: uncaught CTFE exception std.format.FormatException("Cannot format floating point types at compile-time") called from here: to(0.75) pretty simply, trying to

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Johnson via Digitalmars-d-learn
On Monday, 14 August 2017 at 03:44:27 UTC, Adam D. Ruppe wrote: On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: pretty simply, trying to convert a floating point to a string in a ctfe function and it thinks that it is too complex to do in a ctfe, really? It uses a C function

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, August 12, 2017 18:57:44 Arek via Digitalmars-d-learn wrote: > I have the folowing problem: > I like to envelope the class object in struct to control the > destruction moment and then send this object to another > thread/fiber (or task, cause I use vibe-d). > > I can't find any

WebCam or Video in D

2017-08-13 Thread brian via Digitalmars-d-learn
Howdy folks. Has anyone gotten an example of using D as mechanism to read in video files, specifically from a webcam? I don't see any OpenCV libraries, and the example in the DCV library that uses FFMPEG, I can't get to work (I've raised an issue in Github here

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 13, 2017 16:40:03 crimaniak via Digitalmars-d-learn wrote: > More of this, I think, you can't avoid __gshared for any complex > work. Even mutexes from Phobos doesn't support shared, so I had > to 'cowboy with __gshared' when implementing my site engine. The way to handle shared

Re: Read/Write memory barriers in D?

2017-08-13 Thread Igor via Digitalmars-d-learn
On Sunday, 13 August 2017 at 11:58:56 UTC, Daniel Kozak wrote: or maybe use core.atomic.atomicLoad and store with right https://dlang.org/phobos/core_atomic.html#.MemoryOrder On Sun, Aug 13, 2017 at 1:51 PM, Daniel Kozak wrote: maybe something like

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-13 Thread crimaniak via Digitalmars-d-learn
On Sunday, 13 August 2017 at 11:35:05 UTC, Arek wrote: Yeah, I've read this. But conurrency.send cannot pass immutable object. The same story with Unique. Sorry, read this as 'efficient immutable'. More over, "shared" looks rather like unfinished concept. Yes, exactly. Anyway, _gshared

Re: html fetcher/parser

2017-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 13 August 2017 at 15:54:45 UTC, Faux Amis wrote: Just curious, but is there a spec of sorts which defines which errors should be fixed and such? The HTML5 spec describes how you are supposed to parse various things, including the recovery paths for broken markup. My module,

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 07:30:32 UTC, Daniel Kozak wrote: Here is more D idiomatic way: import std.stdio : writeln; import std.algorithm.comparison: min; import std.algorithm.iteration: sum; import core.time: MonoTime, Duration; auto sum_subranges(T)(T input, uint range) { import

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it seems to be almost same On Sun, Aug 13, 2017 at 9:51 AM, amfvcg via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Sunday, 13 August 2017 at 07:30:32 UTC, Daniel Kozak wrote: >

Re: Launch and obtain thread output during compile time

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 07:37:15 UTC, data pulverizer wrote: Hi all, Is it possible to launch/spawn a thread/fibre or some other appropriate item and obtain an immutable/enum or some appropriate output at compile-time? For instance return an immutable(string) from the external thread to

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote: my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it seems to be almost same Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste (ldc 0.12.0) it gets killed. What version are you using?

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
this one is even faster than c++: http://ideone.com/TRDsOo On Sun, Aug 13, 2017 at 10:00 AM, Daniel Kozak wrote: > my second version on ldc takes 380ms and c++ version on same compiler > (clang), takes 350ms, so it seems to be almost same > > On Sun, Aug 13, 2017 at 9:51 AM,

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread ikod via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote: On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote: my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it seems to be almost same Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote: On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote: my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it seems to be almost same Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
Gives me 5 μs and 2 hnsecs 5000 3 secs, 228 ms, 837 μs, and 4 hnsecs 5000 And you've compiled it with? Btw. clang for c++ version works worse than gcc (for this case [112ms vs 180ms]).

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Daniel Kozak via Digitalmars-d-learn
And this one is awesome :P http://ideone.com/muehUw On Sun, Aug 13, 2017 at 10:27 AM, Daniel Kozak wrote: > this one is even faster than c++: > http://ideone.com/TRDsOo > > On Sun, Aug 13, 2017 at 10:00 AM, Daniel Kozak wrote: > >> my second version on ldc

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:29:30 UTC, Petar Kirov [ZombineDev] wrote: On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote: On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote: my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread ikod via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:32:50 UTC, amfvcg wrote: Gives me 5 μs and 2 hnsecs 5000 3 secs, 228 ms, 837 μs, and 4 hnsecs 5000 And you've compiled it with? Btw. clang for c++ version works worse than gcc (for this case [112ms vs 180ms]). DMD64 D Compiler v2.074.1

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:33:53 UTC, Petar Kirov [ZombineDev] wrote: With Daniel's latest version ( http://forum.dlang.org/post/mailman.5963.1502612885.31550.digitalmars-d-le...@puremagic.com ) $ ldc2 -O3 --release sum_subranges2.d $ ./sum_subranges2 210 ms, 838 μs, and 8 hnsecs

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:43:29 UTC, amfvcg wrote: On Sunday, 13 August 2017 at 08:33:53 UTC, Petar Kirov [ZombineDev] wrote: With Daniel's latest version ( http://forum.dlang.org/post/mailman.5963.1502612885.31550.digitalmars-d-le...@puremagic.com ) $ ldc2 -O3 --release

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov [ZombineDev] wrote: There's one especially interesting result: This instantiation: sum_subranges(std.range.iota!(int, int).iota(int, int).Result, uint) of the following function: auto sum_subranges(T)(T input, uint range) { import

Re: Launch and obtain thread output during compile time

2017-08-13 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:09:28 UTC, Petar Kirov [ZombineDev] wrote: On Sunday, 13 August 2017 at 07:37:15 UTC, data pulverizer wrote: Hi all, Is it possible to launch/spawn a thread/fibre or some other appropriate item and obtain an immutable/enum or some appropriate output at

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov [ZombineDev] wrote: This instantiation: sum_subranges(std.range.iota!(int, int).iota(int, int).Result, uint) of the following function: auto sum_subranges(T)(T input, uint range) { import std.range : chunks, ElementType, array;

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Johan Engelen via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:15:48 UTC, amfvcg wrote: Change the parameter for this array size to be taken from stdin and I assume that these optimizations will go away. This is paramount for all of the testing, examining, and comparisons that are discussed in this thread. Full

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:41:39 UTC, Johan Engelen wrote: On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov [ZombineDev] wrote: [...] [...] Execution of sum_subranges is already O(1), because the calculation of the sum is delayed: the return type of the function is not