Re: How to be more careful about null pointers?

2016-03-29 Thread cy via Digitalmars-d-learn
On Monday, 28 March 2016 at 21:24:48 UTC, Adam D. Ruppe wrote: If it didn't give the error, either you swallowed it or you didn't actually dereference null. Okay, so it's not actually supposed to happen. Hopefully it's something I did wrong... What is the db library you are using? Did you

Error: template instance does not match template declaration

2016-03-29 Thread ref2401 via Digitalmars-d-learn
OS: Win 8.1 Pro DMD: v2.070.0 cmd: dmd main.d -ofconsole-app.exe -debug -unittest -wi Code is successfully compiled until I uncomment test1 function call in the main. If it's uncommented I get the following compile-time error: main.d(58): Error: template instance impl!(string, bool,

Re: Error: template instance does not match template declaration

2016-03-29 Thread ref2401 via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 18:29:27 UTC, Ali Çehreli wrote: On 03/29/2016 11:21 AM, ref2401 wrote: So, dict is a template value parameter of type T[string]. I don't think you can use an associative array as a template value parameter. (Can we?) However, it is possible to use anything as

Re: How to be more careful about null pointers?

2016-03-29 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 29 Mar 2016 06:00:32 + schrieb cy : > struct Database { >string derp; >Statement prepare(string s) { > return Statement(1234); >} > } > > struct Statement { >int member; >void bind(int column, int value) { > import std.stdio; >

Re: Joining AliasSeq/TypeTuple s

2016-03-29 Thread Ali Çehreli via Digitalmars-d-learn
On 03/29/2016 02:33 AM, Voitech wrote: Hi, i want to join two or more tupples in to one, with mixing the indexes like roundRobin but in compile time. unittest{ import std.meta; alias first=AliasSeq!(int, string,bool); alias second=AliasSeq!("abc","def","ghi"); alias third=... static

Re: I need some help benchmarking SoA vs AoS

2016-03-29 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 26 March 2016 at 17:43:48 UTC, maik klein wrote: On Saturday, 26 March 2016 at 17:06:39 UTC, ag0aep6g wrote: On 26.03.2016 18:04, ag0aep6g wrote: https://gist.github.com/aG0aep6G/a1b87df1ac5930870ffe/revisions PS: Those enforces are for a size of 100_000 not 1_000_000, because

Re: How to be more careful about null pointers?

2016-03-29 Thread Ali Çehreli via Digitalmars-d-learn
On 03/29/2016 11:57 AM, cy wrote: > On Tuesday, 29 March 2016 at 06:21:49 UTC, Ali Çehreli wrote: >> parent.prep.bind is translated to the following by the compiler: >> >> "Call bind() for the object at address... let's calculate... Wherever >> parent is, we should add the offset of prep inside

Re: Error: template instance does not match template declaration

2016-03-29 Thread Ali Çehreli via Digitalmars-d-learn
On 03/29/2016 11:21 AM, ref2401 wrote: > private void impl(S, T, T[string] dict)(S arg) { > writeln("S: ", S.stringof); > writeln("T: ", T.stringof); > writeln("dict: ", dict); So, dict is a template value parameter of type T[string]. I don't think you can use an associative

Re: How to be more careful about null pointers?

2016-03-29 Thread cy via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 06:21:49 UTC, Ali Çehreli wrote: parent.prep.bind is translated to the following by the compiler: "Call bind() for the object at address... let's calculate... Wherever parent is, we should add the offset of prep inside that object." Okay, that's helpful

Re: char array weirdness

2016-03-29 Thread Marco Leise via Digitalmars-d-learn
Am Mon, 28 Mar 2016 16:29:50 -0700 schrieb "H. S. Teoh via Digitalmars-d-learn" : > […] your diacritics may get randomly reattached to > stuff they weren't originally attached to, or you may end up with wrong > sequences of Unicode code points (e.g. diacritics

Part of D available to run at compile time

2016-03-29 Thread Carl Sturtivant via Digitalmars-d-learn
is there documentation on which parts of D are available to compile time execution?

key in aa.keys, but aa[key] give range violation?

2016-03-29 Thread Yuxuan Shui via Digitalmars-d-learn
My code looks something like this: bool[ulong][ulong] edge; foreach(u; from) foreach(v; to_) edge[u][v] = true; foreach(u; edge.keys) { auto adj = edge[u]; // } And sometimes edge[u] would give Range violation error.

Re: key in aa.keys, but aa[key] give range violation?

2016-03-29 Thread Ali Çehreli via Digitalmars-d-learn
On 03/29/2016 05:29 PM, Yuxuan Shui wrote: On Wednesday, 30 March 2016 at 00:26:49 UTC, Yuxuan Shui wrote: My code looks something like this: bool[ulong][ulong] edge; foreach(u; from) foreach(v; to_) edge[u][v] = true; foreach(u; edge.keys) { auto adj = edge[u]; // }

Re: Part of D available to run at compile time

2016-03-29 Thread Ali Çehreli via Digitalmars-d-learn
On 03/29/2016 03:29 PM, Carl Sturtivant wrote: is there documentation on which parts of D are available to compile time execution? This seems to be the official spec: https://dlang.org/spec/function.html#interpretation See you at DConf! ;) Ali

Debugging D DLL from C# app with C linkage for native Unity 5 plugin

2016-03-29 Thread Thalamus via Digitalmars-d-learn
Apologies if this has been discussed before, but I wasn't able to find anything similar on the forums or web. I can't seem to figure out how to debug a D DLL from a C# EXE. (My actual purpose here is to use D to build native plugins for Unity 5, but Unity and Mono aren't necessary to repro the

Re: char array weirdness

2016-03-29 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 23:15:26 UTC, Basile B. wrote: I've seen you so many time as a reviewer on dlang that I belive this Q is a joke. Even if obviously nobody can know everything... https://www.youtube.com/watch?v=l97MxTx0nzs seriously you didn't know that auto decoding is on and that

Re: char array weirdness

2016-03-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/29/16 7:42 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Mar 29, 2016 at 11:15:26PM +, Basile B. via Digitalmars-d-learn wrote: On Monday, 28 March 2016 at 22:34:31 UTC, Jack Stouffer wrote: void main () { import std.range.primitives; char[] val = ['1', '0', 'h', '3',

Re: char array weirdness

2016-03-29 Thread Basile B. via Digitalmars-d-learn
On Monday, 28 March 2016 at 22:34:31 UTC, Jack Stouffer wrote: void main () { import std.range.primitives; char[] val = ['1', '0', 'h', '3', '6', 'm', '2', '8', 's']; pragma(msg, ElementEncodingType!(typeof(val))); pragma(msg, typeof(val.front)); } prints char dchar

Re: char array weirdness

2016-03-29 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 00:05:29 UTC, Steven Schveighoffer wrote: On 3/29/16 7:42 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Mar 29, 2016 at 11:15:26PM +, Basile B. via Digitalmars-d-learn wrote: On Monday, 28 March 2016 at 22:34:31 UTC, Jack Stouffer wrote: void main ()

Re: key in aa.keys, but aa[key] give range violation?

2016-03-29 Thread Yuxuan Shui via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 00:26:49 UTC, Yuxuan Shui wrote: My code looks something like this: bool[ulong][ulong] edge; foreach(u; from) foreach(v; to_) edge[u][v] = true; foreach(u; edge.keys) { auto adj = edge[u]; // } And sometimes edge[u] would give Range

Re: How to be more careful about null pointers?

2016-03-29 Thread QAston via Digitalmars-d-learn
On Monday, 28 March 2016 at 21:01:19 UTC, cy wrote: I finally found the null pointer. It took a week. I was assigning "db = db" when I should have been assigning "this.db = db". Terrible, I know. But... I invoked db.find_chapter.bindAll(8,4), when db was a null pointer. There was no null

Re: char array weirdness

2016-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 29, 2016 at 11:15:26PM +, Basile B. via Digitalmars-d-learn wrote: > On Monday, 28 March 2016 at 22:34:31 UTC, Jack Stouffer wrote: > >void main () { > >import std.range.primitives; > >char[] val = ['1', '0', 'h', '3', '6', 'm', '2', '8', 's']; > >pragma(msg,

Re: How to be more careful about null pointers?

2016-03-29 Thread Ali Çehreli via Digitalmars-d-learn
On 03/28/2016 11:00 PM, cy wrote: > struct Database { >string derp; >Statement prepare(string s) { > return Statement(1234); >} > } > > struct Statement { >int member; >void bind(int column, int value) { > import std.stdio; > writeln("derp",member); Change

Re: char array weirdness

2016-03-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 28, 2016 16:29:50 H. S. Teoh via Digitalmars-d-learn wrote: > On Mon, Mar 28, 2016 at 04:07:22PM -0700, Jonathan M Davis via > Digitalmars-d-learn wrote: [...] > > > The range API considers all strings to have an element type of dchar. > > char, wchar, and dchar are UTF code units

Re: string and char[] in Phobos

2016-03-29 Thread Puming via Digitalmars-d-learn
On Friday, 18 March 2016 at 20:06:27 UTC, Jonathan M Davis wrote: When a function accepts const(char)[] than it can accept char[], const(char)[], const(char[]), immutable(char)[], and immutable(char[]), which, whereas if it accepts string, then all it accepts are immutable(char)[] and

Joining AliasSeq/TypeTuple s

2016-03-29 Thread Voitech via Digitalmars-d-learn
Hi, i want to join two or more tupples in to one, with mixing the indexes like roundRobin but in compile time. unittest{ import std.meta; alias first=AliasSeq!(int, string,bool); alias second=AliasSeq!("abc","def","ghi"); alias third=... static assert(third==AliasSeq!(int, "abc", string,

Re: Joining AliasSeq/TypeTuple s

2016-03-29 Thread Adrian Matoga via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 09:33:40 UTC, Voitech wrote: Hi, i want to join two or more tupples in to one, with mixing the indexes like roundRobin but in compile time. unittest{ import std.meta; alias first=AliasSeq!(int, string,bool); alias second=AliasSeq!("abc","def","ghi"); alias

infer type argument in classe constructor?

2016-03-29 Thread Puming via Digitalmars-d-learn
Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main() { Message[] src = ...; auto decoder = new Decoder!(Message[])(src); ... } ``` Can it be inferred so that I only

Re: infer type argument in classe constructor?

2016-03-29 Thread Simen Kjaeraas via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 10:13:28 UTC, Puming wrote: Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main() { Message[] src = ...; auto decoder = new

Re: infer type argument in classe constructor?

2016-03-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 10:13:28 UTC, Puming wrote: Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main() { Message[] src = ...; auto decoder = new

Re: parsing fastq files with D

2016-03-29 Thread eastanon via Digitalmars-d-learn
On Thursday, 24 March 2016 at 06:34:51 UTC, rikki cattermole wrote: void popFront() { import std.string : indexOf; if (source is null) {

Re: infer type argument in classe constructor?

2016-03-29 Thread Puming via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 10:29:46 UTC, Simen Kjaeraas wrote: On Tuesday, 29 March 2016 at 10:13:28 UTC, Puming wrote: Hi, I'm writing a generic class: ```d struct Message { ... } class Decoder(MsgSrc) { } ``` When using it, I'd have to include the type of its argument: ``` void main()

Re: parsing fastq files with D

2016-03-29 Thread rikki cattermole via Digitalmars-d-learn
On 30/03/2016 1:46 AM, eastanon wrote: On Thursday, 24 March 2016 at 06:34:51 UTC, rikki cattermole wrote: void popFront() { import std.string : indexOf; if (source is null) { isEmpty = true; return;

Re: I need some help benchmarking SoA vs AoS

2016-03-29 Thread maik klein via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 21:27:15 UTC, ZombineDev wrote: On Saturday, 26 March 2016 at 17:43:48 UTC, maik klein wrote: On Saturday, 26 March 2016 at 17:06:39 UTC, ag0aep6g wrote: On 26.03.2016 18:04, ag0aep6g wrote: https://gist.github.com/aG0aep6G/a1b87df1ac5930870ffe/revisions PS:

Re: char array weirdness

2016-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 30, 2016 at 03:22:48AM +, Jack Stouffer via Digitalmars-d-learn wrote: > On Tuesday, 29 March 2016 at 23:42:07 UTC, H. S. Teoh wrote: > >Believe it or not, it was only last year (IIRC, maybe the year > >before) that Walter "discovered" that Phobos does autodecoding, and > >got

Re: char array weirdness

2016-03-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 29, 2016 at 08:05:29PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > Phobos treats narrow strings (wchar[], char[]) as ranges of dchar. It > was discovered that auto decoding strings isn't always the smartest > thing to do, especially for performance. > > So you

Re: Part of D available to run at compile time

2016-03-29 Thread rikki cattermole via Digitalmars-d-learn
On 30/03/2016 11:29 AM, Carl Sturtivant wrote: is there documentation on which parts of D are available to compile time execution? Rule of thumb, if it can be pure and @safe, you're good to go.

Re: char array weirdness

2016-03-29 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 29 March 2016 at 23:42:07 UTC, H. S. Teoh wrote: Believe it or not, it was only last year (IIRC, maybe the year before) that Walter "discovered" that Phobos does autodecoding, and got pretty upset over it. If even Walter wasn't aware of this for that long... The link (I think