Re: Template recursion error on table struct

2016-03-25 Thread Ali Çehreli via Digitalmars-d-learn
WARNING: Do not try to compile this code. Your computer may be unresponsive for a while. :) On 03/25/2016 02:54 PM, data pulverizer wrote: > I am attempting to create a table struct with generic column types using > templates. However, the template arguments are not types; rather, aliases. > t

Re: byChunk odd behavior?

2016-03-25 Thread Hanh via Digitalmars-d-learn
On Friday, 25 March 2016 at 08:01:04 UTC, cym13 wrote: // This consume auto buffer3 = range.take(4).array; assert(buffer3 == [0, 5, 10, 15]); } Thanks for your help. However the last statement is incorrect. I am in fact looking for a version of 'take' that consumes

Re: Random Access I/O

2016-03-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 26 March 2016 at 00:10:23 UTC, Chris Williams wrote: None of the access modes for std.stdio.File seem to allow that. Any usage of the "w" mode causes my code to consider the file empty if it pre-exists (though, it doesn't always actually truncate the disk on file?) Mode "a+" or "

Re: Initializing global delegate variable - bug or on purpose?

2016-03-25 Thread data pulverizer via Digitalmars-d-learn
On Friday, 25 March 2016 at 23:40:37 UTC, data pulverizer wrote: On Friday, 25 March 2016 at 20:54:28 UTC, Atila Neves wrote: int delegate(int) dg = (i) => i * 2; Error: non-constant nested delegate literal expression __lambda3 int delegate(int) dg; static this() { dg = i => i * 2; // o

Re: Random Access I/O

2016-03-25 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 26 March 2016 at 00:10:23 UTC, Chris Williams wrote: I need to be able to perform random access I/O against a file, creating a new file if it doesn't exist, or opening as-is (no truncation) if it already exists. None of the access modes for std.stdio.File seem to allow that. Any

Random Access I/O

2016-03-25 Thread Chris Williams via Digitalmars-d-learn
I need to be able to perform random access I/O against a file, creating a new file if it doesn't exist, or opening as-is (no truncation) if it already exists. None of the access modes for std.stdio.File seem to allow that. Any usage of the "w" mode causes my code to consider the file empty if

Re: Initializing global delegate variable - bug or on purpose?

2016-03-25 Thread data pulverizer via Digitalmars-d-learn
On Friday, 25 March 2016 at 20:54:28 UTC, Atila Neves wrote: int delegate(int) dg = (i) => i * 2; Error: non-constant nested delegate literal expression __lambda3 int delegate(int) dg; static this() { dg = i => i * 2; // ok } Am I doing anything wrong? Atila Hmm, looks like your first

Re: Strange behavior in console with UTF-8

2016-03-25 Thread Jonathan Villa via Digitalmars-d-learn
On Friday, 25 March 2016 at 13:58:44 UTC, Steven Schveighoffer wrote: On 3/24/16 8:54 PM, Jonathan Villa wrote: [...] D's File i/o uses C's FILE * i/o system. At least on Windows, this has literally zero support for wchar (you can set stream width, and the library just ignores it). What is

Re: Template recursion error on table struct

2016-03-25 Thread data pulverizer via Digitalmars-d-learn
p.s. I realise that the ColumnTable call is a little ponderous but I tidy it up in a convenience wrapper function: auto CreateDataTable(Args...)(){ string[] names; foreach(i, arg; Args){ names ~= Args[i].stringof; } auto df = ColumnTable!(Args)(Arg

Template recursion error on table struct

2016-03-25 Thread data pulverizer via Digitalmars-d-learn
I am attempting to create a table struct with generic column types using templates. The subTable() member function subsets the table, however I am getting a template recursion error. I know where the problem is from, I don't know how to resolve it. I am modelling it after the matrix example in

Initializing global delegate variable - bug or on purpose?

2016-03-25 Thread Atila Neves via Digitalmars-d-learn
int delegate(int) dg = (i) => i * 2; Error: non-constant nested delegate literal expression __lambda3 int delegate(int) dg; static this() { dg = i => i * 2; // ok } Am I doing anything wrong? Atila

Re: rawWrite of a struct suggestions

2016-03-25 Thread Charles Hixson via Digitalmars-d-learn
On 03/25/2016 11:32 AM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Friday, 25 March 2016 at 18:25:28 UTC, Charles Hixson wrote: But when I try to cast a Chnk to a ubyte[], I get an error, and rawWrite takes a generic array of anything... you should be able to rawWrite((&your_object)[0 .

Re: rawWrite of a struct suggestions

2016-03-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 25 March 2016 at 18:25:28 UTC, Charles Hixson wrote: But when I try to cast a Chnk to a ubyte[], I get an error, and rawWrite takes a generic array of anything... you should be able to rawWrite((&your_object)[0 .. 1])

rawWrite of a struct suggestions

2016-03-25 Thread Charles Hixson via Digitalmars-d-learn
I've got a simple struct: structChnk { ulongid; char[20]wrd; ubytelength; ...<--various utility functions and constructors } That I'm trying to write to a file. I want to use an unformatted read/write because I want this to be a random access file. But

Re: getOverloads, but also include all the imported members

2016-03-25 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 24 March 2016 at 15:52:49 UTC, Adam D. Ruppe wrote: On Thursday, 24 March 2016 at 15:07:09 UTC, Yuxuan Shui wrote: Is there a way to do this automatically? No. You have to decide to bring them together if you want them to overload. Oh, sorry, this is not what I meant. What I w

Re: Strange behavior in console with UTF-8

2016-03-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/24/16 8:54 PM, Jonathan Villa wrote: I prefer to post this thing here because it could that I'm doing something wrong. I'm using std.stdio -> readln() to read whatever I'm typing in the console. BUT, if the line contains some UTF-8 characters, the data obtained is EMPTY and module runnab

Re: Struct array assignment behaviour using example from Programming in D, chapter 78

2016-03-25 Thread data pulverizer via Digitalmars-d-learn
On Friday, 25 March 2016 at 08:53:20 UTC, Ali Çehreli wrote: On 03/25/2016 12:00 AM, data pulverizer wrote: > On Thursday, 24 March 2016 at 18:46:14 UTC, Ali Çehreli wrote: >> On 03/24/2016 10:24 AM, data pulverizer wrote: >> > I have been playing with the matrix example given at the end >> of ch

Re: Struct array assignment behaviour using example from Programming in D, chapter 78

2016-03-25 Thread Ali Çehreli via Digitalmars-d-learn
On 03/25/2016 12:00 AM, data pulverizer wrote: > On Thursday, 24 March 2016 at 18:46:14 UTC, Ali Çehreli wrote: >> On 03/24/2016 10:24 AM, data pulverizer wrote: >> > I have been playing with the matrix example given at the end >> of chapter >> > 78 of Ali Çehreli's >> >> For reference, it's "Mult

Re: byChunk odd behavior?

2016-03-25 Thread cym13 via Digitalmars-d-learn
On Thursday, 24 March 2016 at 07:52:27 UTC, Hanh wrote: On Wednesday, 23 March 2016 at 19:07:34 UTC, cym13 wrote: In Scala, 'take' consumes bytes from the iterator. So the same code would be buffer = range.take(N).toArray Then just do that! import std.range, std.array; auto buffer =

Re: Struct array assignment behaviour using example from Programming in D, chapter 78

2016-03-25 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 24 March 2016 at 18:46:14 UTC, Ali Çehreli wrote: On 03/24/2016 10:24 AM, data pulverizer wrote: > I have been playing with the matrix example given at the end of chapter > 78 of Ali Çehreli's For reference, it's "Multi-dimensional operator overloading example" here: http://ddi