How do I send a message to a struct member function?

2017-08-25 Thread Enjoys Math via Digitalmars-d-learn
I have a series of structs each of which needs to spawn a worker thread on initialization. There seems to be no way to send a message back to the struct for instance to cause a member function call on /that/ structs data. Please advise me.

Re: Best syntax for a diagonal and vertical slice

2017-08-25 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 22 July 2017 at 20:55:06 UTC, kerdemdemir wrote: We have awesome way for creating slices like: a = new int[5]; int[] b = a[0..2]; But what about if I have 2D array and I don't want to go vertical. Something like : int[3][3] matrix = [ [ 1, 2, 3 ], [ 4, 5, 6 ],

Re: pipeProcess not returning immediately

2017-08-25 Thread user1234 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 01:13:35 UTC, Johnson Jones wrote: I am running ffplay.exe and my application does not return immediately from pipeProcess. I have to close ffplay for my program to continue execution. No process is asynchronous in std.process. If you don't want to block your pr

Re: 2 Dimensional Array Sorting

2017-08-25 Thread user1234 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 06:11:37 UTC, user1234 wrote: On Saturday, 26 August 2017 at 06:01:15 UTC, Vino.B wrote: Hi, Can someone provide me a example of sorting 2 Dimensional Array containing Filename and Size, and should be sorted by Size. From, Vino.B void main(string[] args) {

Re: 2 Dimensional Array Sorting

2017-08-25 Thread user1234 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 06:01:15 UTC, Vino.B wrote: Hi, Can someone provide me a example of sorting 2 Dimensional Array containing Filename and Size, and should be sorted by Size. From, Vino.B void main(string[] args) { import std.stdio; import std.algorithm.sorting; s

2 Dimensional Array Sorting

2017-08-25 Thread Vino.B via Digitalmars-d-learn
Hi, Can someone provide me a example of sorting 2 Dimensional Array containing Filename and Size, and should be sorted by Size. From, Vino.B

pipeProcess not returning immediately

2017-08-25 Thread Johnson Jones via Digitalmars-d-learn
I am running ffplay.exe and my application does not return immediately from pipeProcess. I have to close ffplay for my program to continue execution. pipeProcess is suppose to return immediately/run asynchronously, and it does with ffmpeg or other programs that return. (which I do not know if

Re: wrapping a C style delegate

2017-08-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 26 August 2017 at 00:27:47 UTC, Ali Çehreli wrote: I think you need a variation of intermediateCallback() below. I passed the address of the delegate as userData but you can construct any context that contains everything that you need (e.g. the address of ms). import std.stdio;

Re: wrapping a C style delegate

2017-08-25 Thread Ali Çehreli via Digitalmars-d-learn
On 08/25/2017 04:00 PM, Nicholas Wilson wrote: On Friday, 25 August 2017 at 13:49:20 UTC, Kagamin wrote: You're not specific enough. What would be semantics of such wrapper? The C function I'm trying to wrap takes a function pointer which is essentially a delegate, but not quite: ErrorEnum fu

Re: wrapping a C style delegate

2017-08-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 August 2017 at 13:49:20 UTC, Kagamin wrote: You're not specific enough. What would be semantics of such wrapper? The C function I'm trying to wrap takes a function pointer which is essentially a delegate, but not quite: ErrorEnum function(Struct* s, void function(Struct*, Error

How do I create a fileWatcher with an onFileChange event using spawn?

2017-08-25 Thread Enjoys Math via Digitalmars-d-learn
Something like this: module file_watcher; import std.concurrency; import std.file; import std.signals; import std.datetime; void fileWatcher(Tid tid, string filename, int loopSleep) { auto modified0 = timeLastModified(filename); while (true) { modified = tim

Re: testing for deprecation

2017-08-25 Thread jmh530 via Digitalmars-d-learn
On Thursday, 1 September 2016 at 11:13:42 UTC, rikki cattermole wrote: That is a first that somebody wanted it. Bug report please! I just ran across this with deprecated { void foo(); } void main() { pragma(msg, __traits(getAttributes, foo)); } producing just tuple(). I came across t

spawnProcess: Exit parent process without terminating child process

2017-08-25 Thread timvol via Digitalmars-d-learn
Hi guys, I want execute a process. I know, I can execute a process using "spawnProcess" or "executeShell". But I want exit the parent. My code for testing purposes is the following: int main(string[] asArgs_p) { if ( (asArgs_p.length >= 2) && asArgs_p[1].isDir() ) { while(1) {

Re: (SIMD) Optimized multi-byte chunk scanning

2017-08-25 Thread Nordlöw via Digitalmars-d-learn
On Friday, 25 August 2017 at 09:40:28 UTC, Igor wrote: As for a nice reference of intel intrinsics: https://software.intel.com/sites/landingpage/IntrinsicsGuide/ Wow, what a fabulous UX!

Re: Multi dimensional array format priting

2017-08-25 Thread Vino.B via Digitalmars-d-learn
On Friday, 25 August 2017 at 17:41:31 UTC, Vino.B wrote: On Friday, 25 August 2017 at 17:02:53 UTC, Jonathan M Davis wrote: On Friday, August 25, 2017 16:45:16 Vino.B via Digitalmars-d-learn wrote: Hi, Request your help on the below issue, Issue : While appending data to a array the data is

Re: Choosing between enum arrays or AliasSeqs

2017-08-25 Thread Nordlöw via Digitalmars-d-learn
On Friday, 25 August 2017 at 08:27:41 UTC, Jacob Carlborg wrote: Since you're converting the returned index to a bool, can't you use "canFind" instead? immutable englishIndefiniteArticles = [`a`, `an`]; bool isEnglishIndefiniteArticle(S)(S s) { return englishIndefiniteArticles.canFind(s); }

Re: Appending data to array results in duplicate's.

2017-08-25 Thread Vino.B via Digitalmars-d-learn
On Friday, 25 August 2017 at 17:02:53 UTC, Jonathan M Davis wrote: On Friday, August 25, 2017 16:45:16 Vino.B via Digitalmars-d-learn wrote: Hi, Request your help on the below issue, Issue : While appending data to a array the data is getting duplicated. Program: import std.file: dirEntri

Re: Appending data to array results in duplicate's.

2017-08-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 25, 2017 16:45:16 Vino.B via Digitalmars-d-learn wrote: > Hi, > > Request your help on the below issue, > > Issue : While appending data to a array the data is getting > duplicated. > > Program: > import std.file: dirEntries, isFile, SpanMode; > import std.stdio: writeln, writef

Re: Appending data to array results in duplicate's.

2017-08-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 25 August 2017 at 16:45:16 UTC, Vino.B wrote: Hi, Request your help on the below issue, Issue : While appending data to a array the data is getting duplicated. Program: import std.file: dirEntries, isFile, SpanMode; import std.stdio: writeln, writefln; import std.algorithm: filte

Appending data to array results in duplicate's.

2017-08-25 Thread Vino.B via Digitalmars-d-learn
Hi, Request your help on the below issue, Issue : While appending data to a array the data is getting duplicated. Program: import std.file: dirEntries, isFile, SpanMode; import std.stdio: writeln, writefln; import std.algorithm: filter, map; import std.array: array; import std.typecons: tupl

Re: Long File path Exception:The system cannot find the path specified

2017-08-25 Thread Vino.B via Digitalmars-d-learn
On Friday, 25 August 2017 at 09:08:44 UTC, zabruk70 wrote: On Thursday, 24 August 2017 at 18:02:24 UTC, vino wrote: Thanks for your support, was able to resolve this issue. Hello. IMHO, it will be better, if you will share your solution for other peoples :) Hi, Please find the solution

Re: wrapping a C style delegate

2017-08-25 Thread Kagamin via Digitalmars-d-learn
You're not specific enough. What would be semantics of such wrapper?

Re: (SIMD) Optimized multi-byte chunk scanning

2017-08-25 Thread Igor via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 22:07:30 UTC, Nordlöw wrote: I recall seeing some C/C++/D code that optimizes the comment- and whitespace-skipping parts (tokens) of lexers by operating on 2, 4 or 8-byte chunks instead of single-byte chunks. This in the case when token-terminators are expressed

Re: Long File path Exception:The system cannot find the path specified

2017-08-25 Thread zabruk70 via Digitalmars-d-learn
On Thursday, 24 August 2017 at 18:02:24 UTC, vino wrote: Thanks for your support, was able to resolve this issue. Hello. IMHO, it will be better, if you will share your solution for other peoples :)

Re: Choosing between enum arrays or AliasSeqs

2017-08-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-25 08:12, Nordlöw wrote: Thanks! Your advice led to the following sample solution import std.meta : aliasSeqOf; immutable englishIndefiniteArticles = [`a`, `an`]; bool isEnglishIndefiniteArticle(S)(S s) {     return cast(bool)s.among!(aliasSeqOf!englishIndefiniteArticles); } Is th

Re: Web servers in D

2017-08-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-25 07:25, Hasen Judy wrote: What libraries are people using to run webservers other than vibe.d? Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd. I think for D to a have good web story i

Re: Terminating a thread (which is blocking)

2017-08-25 Thread Eugene Wissner via Digitalmars-d-learn
On Thursday, 24 August 2017 at 07:23:15 UTC, Timothy Foster wrote: I've started a thread at the beginning of my program that waits for user input: `thread = new Thread(&checkInput).start;` `static void checkInput(){ foreach (line; stdin.byLineCopy) { ... } }` I need to stop checking for u

Re: Web servers in D

2017-08-25 Thread Hasen Judy via Digitalmars-d-learn
On Friday, 25 August 2017 at 06:15:35 UTC, Eugene Wissner wrote: There is collie [1]. Never used. Can't say a lot about it. arsd [2] has a lot of interesting web stuff: event loop, FastCGI/SimpleCGI; web-, DOM-, mail-utilities. And the last but not least I'm running currently a small web se

Re: Tools to help me find memory leaks?

2017-08-25 Thread Sebastien Alaiwan via Digitalmars-d-learn
I always use "valgrind --tool=massif" + "massif-visualizer". Gives me a nice timeline allowing to find quickly who the big memory consumers (allocation sites) are.