Re: byChunk odd behavior?

2016-03-22 Thread Hanh via Digitalmars-d-learn
Thanks for your help everyone. I agree that the issue is due to the misusage of an InputRange but what is the semantics of 'take' when applied to an InputRange? It seems that calling it invalidates the range; in which case what is the recommended way to get a few bytes and keep on advancing.

Re: Using ffmpeg in command line with D

2016-03-22 Thread cy via Digitalmars-d-learn
On Monday, 21 March 2016 at 17:26:09 UTC, Karabuta wrote: Will this work Yes. and is it the right approach used by video convertor front-ends? Well, yes, provisionally. When you invoke "ffmpeg" via spawnProcess, that isolates ffmpeg as its own process, obviously. From a security and

Re: byChunk odd behavior?

2016-03-22 Thread cy via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 07:17:41 UTC, Hanh wrote: input.take(3).array; foreach (char c; input) { Never use an input range twice. So, here's how to use it twice: If it's a "forward range" you can use save() to get a copy to use later (but all the std.stdio.* ranges don't

Re: byChunk odd behavior?

2016-03-22 Thread Ali Çehreli via Digitalmars-d-learn
On 03/22/2016 12:17 AM, Hanh wrote: > Hi all, > > I'm trying to process a rather large file as an InputRange and run into > something strange with byChunk / take. > > void test() { > auto file = new File("test.txt"); > auto input = file.byChunk(2).joiner; > input.take(3).array; >

Re: Something wrong with GC

2016-03-22 Thread ag0aep6g via Digitalmars-d-learn
On 20.03.2016 08:49, stunaep wrote: The gc throws invalid memory errors if I use Arrays from std.container. For example, this throws an InvalidMemoryOperationError: import std.stdio; import std.container; void main() { new Test(); } class Test { private Array!string test =

Re: Something wrong with GC

2016-03-22 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 13:46:41 UTC, stunaep wrote: public class Example2 { private int one; private int two; public this(int one, int two) { this.one = one; this.two = two; } } in a tree map and list of

Re: byChunk odd behavior?

2016-03-22 Thread Taylor Hillegeist via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 07:17:41 UTC, Hanh wrote: Hi all, I'm trying to process a rather large file as an InputRange and run into something strange with byChunk / take. void test() { auto file = new File("test.txt"); auto input = file.byChunk(2).joiner;

Re: Something wrong with GC

2016-03-22 Thread stunaep via Digitalmars-d-learn
On Monday, 21 March 2016 at 07:55:39 UTC, thedeemon wrote: On Sunday, 20 March 2016 at 07:49:17 UTC, stunaep wrote: The gc throws invalid memory errors if I use Arrays from std.container. Those arrays are for RAII-style deterministic memory release, they shouldn't be freely mixed with

Re: pass a struct by value/ref and size of the struct

2016-03-22 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 07:35:49 UTC, ZombineDev wrote: If the object is larger than the size of a register on the target machine, it is implicitly passed by ref (i.e. struct fields are accessed by offset from the stack pointer). (Oops, sorry ZombineDev, should've read your reply

Re: pass a struct by value/ref and size of the struct

2016-03-22 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 21 March 2016 at 23:31:06 UTC, ref2401 wrote: I have got a plenty of structs in my project. Their size varies from 12 bytes to 128 bytes. Is there a rule of thumb that states which structs I pass by value and which I should pass by reference due to their size? Note that the

Re: Trying to use Dustmite on windows

2016-03-22 Thread Jerry via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 09:19:27 UTC, Vladimir Panteleev wrote: On Tuesday, 22 March 2016 at 09:11:52 UTC, Jerry wrote: So I want to pass my DUB project to Dustmite and use findstr For reducing dub projects, try the "dub dustmite" command, e.g. "--compiler-regex=Assertion failure".

Re: Trying to use Dustmite on windows

2016-03-22 Thread Vladimir Panteleev via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 09:11:52 UTC, Jerry wrote: So I want to pass my DUB project to Dustmite and use findstr For reducing dub projects, try the "dub dustmite" command, e.g. "--compiler-regex=Assertion failure".

Trying to use Dustmite on windows

2016-03-22 Thread Jerry via Digitalmars-d-learn
I am really not used to bash scripts. I am trying to use Dustmite on my project since I have started getting an "Assertion failure: '0' in glue.c on line 1492" and really can not find any issue about it in the issue tracker. So I want to pass my DUB project to Dustmite and use findstr bash

Re: pass a struct by value/ref and size of the struct

2016-03-22 Thread ZombineDev via Digitalmars-d-learn
On Monday, 21 March 2016 at 23:31:06 UTC, ref2401 wrote: I have got a plenty of structs in my project. Their size varies from 12 bytes to 128 bytes. Is there a rule of thumb that states which structs I pass by value and which I should pass by reference due to their size? Thanks. If the

Re: byChunk odd behavior?

2016-03-22 Thread Hanh via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 07:17:41 UTC, Hanh wrote: Hi all, I'm trying to process a rather large file as an InputRange and run into something strange with byChunk / take. void test() { auto file = new File("test.txt"); auto input = file.byChunk(2).joiner;

byChunk odd behavior?

2016-03-22 Thread Hanh via Digitalmars-d-learn
Hi all, I'm trying to process a rather large file as an InputRange and run into something strange with byChunk / take. void test() { auto file = new File("test.txt"); auto input = file.byChunk(2).joiner; input.take(3).array; foreach (char c; input) {