Re: segfault

2010-11-10 Thread Daniel Murphy
What happens if you make pattern const?

Re: Memory allocation faile on string concat

2010-11-10 Thread Xie
>OK, this actually makes sense to me. >It's a manifestation of this issue: >http://d.puremagic.com/issues/show_bug.cgi?id=3929 I'm think - it's truth but not at all. Sorry, but i'm give incomplete data. My example run fine, when benchmark(1), (2), but not 10. This means, that memory not collect

Re: struct constructors and function parameters

2010-11-10 Thread Adam Burton
Simen kjaeraas wrote: > Adam Burton wrote: > >> I looked into alias this and it does indeed work, unless the alias is to >> a >> function. That has been reported as a bug though >> http://d.puremagic.com/issues/show_bug.cgi?id=2814 > > Wouldn't that be the opposite of what you were discussing e

Re: 2 bool optional params

2010-11-10 Thread Manfred_Nowak
Jonathan M Davis wrote: > Whether they are actually worth having, I really can't say. They are not worth it. Without optional parameters it is already dificult enough to remember for each name of a function the length of the formal parameter list and the sequence of types and meanings for each

Re: 2 bool optional params -- named parameters

2010-11-10 Thread spir
On Wed, 10 Nov 2010 12:39:15 -0800 Jonathan M Davis wrote: > On Wednesday 10 November 2010 12:24:01 bearophile wrote: > > Jonathan M Davis: > > > In any case, the struct solution is the best that I can suggest for the > > > general case, but really, D doesn't have named parameters. Things just >

Re: Converting Fuse headers

2010-11-10 Thread div0
On 10/11/2010 21:02, Jesse Phillips wrote: div0 Wrote: You can still do the size check for the stat_t struct as well, I always double check the size of structs when doing those conversions as it's very easy to get it wrong. Ah, good idea. The test I have planned will be to set some values in

Re: ponce

2010-11-10 Thread Don
Steven Schveighoffer wrote: On Tue, 09 Nov 2010 17:14:33 -0500, Don wrote: bearophile wrote: Jonathan M Davis: it would be possible to make it so that any objects allocated with new during CTFE would be in the dynamic heap during runtime. This is possible, but it doesn't seem what you usua

Re: Converting Fuse headers

2010-11-10 Thread Jesse Phillips
div0 Wrote: > You can still do the size check for the stat_t struct as well, > I always double check the size of structs when doing those conversions > as it's very easy to get it wrong. Ah, good idea. The test I have planned will be to set some values in the D struct, and see what is read by t

Re: Converting Fuse headers

2010-11-10 Thread div0
On 10/11/2010 20:15, Jesse Phillips wrote: div0 Wrote: Well done, glad you proved me wrong. It does seem unlikely that size_t is wrong, though you can test it easily enough: compile a test C program to see what size it is and compare it to the D version: void main() { printf("sizeof:

Re: 2 bool optional params

2010-11-10 Thread Jonathan M Davis
On Wednesday 10 November 2010 12:24:01 bearophile wrote: > Jonathan M Davis: > > In any case, the struct solution is the best that I can suggest for the > > general case, but really, D doesn't have named parameters. Things just > > don't work that way. > > Named arguments is among my top four enha

Re: 2 bool optional params

2010-11-10 Thread bearophile
Jonathan M Davis: > In any case, the struct solution is the best that I can suggest for the > general > case, but really, D doesn't have named parameters. Things just don't work > that > way. Named arguments is among my top four enhancement requests :-) They help. Hopefully in D3. Bye, bear

Re: Converting Fuse headers

2010-11-10 Thread Jesse Phillips
div0 Wrote: > Well done, glad you proved me wrong. > > It does seem unlikely that size_t is wrong, > though you can test it easily enough: > > compile a test C program to see what size it is and compare it to the D > version: > > void main() { > printf("sizeof: %d", sizeof(size_t)); > }

Re: Memory allocation faile on string concat

2010-11-10 Thread Steven Schveighoffer
On Wed, 10 Nov 2010 14:38:02 -0500, Xie wrote: Sorry, it a mistypo (i began from wchar[], later changed to wstring) Real problem can be seen here import std.stdio; import std.date; void f0() { wstring a; foreach(i; 0 .. 100_000_000) { a ~= " "w;

Re: Memory allocation faile on string concat

2010-11-10 Thread Xie
Sorry, it a mistypo (i began from wchar[], later changed to wstring) Real problem can be seen here import std.stdio; import std.date; void f0() { wstring a; foreach(i; 0 .. 100_000_000) { a ~= " "w; } } void main() { auto r = benchmark!(f

Re: Memory allocation faile on string concat

2010-11-10 Thread Steven Schveighoffer
On Wed, 10 Nov 2010 14:06:40 -0500, Steven Schveighoffer wrote: Just tried it, Appender is actually slower. This *is* a problem, it should be way faster than builtin array appending. I will look into it. More data, Appender taking an array of elements is significantly slower than taki

Re: Memory allocation faile on string concat

2010-11-10 Thread Steven Schveighoffer
On Wed, 10 Nov 2010 13:55:26 -0500, sybrandy wrote: On 11/10/2010 11:33 AM, Xie wrote: Can't run a simple program. What's wrong, GC? import std.stdio; import std.date; void f0() { wstring a[]; foreach(i; 0 .. 100_000_000) { a ~= " "w; } } voi

Re: Memory allocation faile on string concat

2010-11-10 Thread sybrandy
On 11/10/2010 11:33 AM, Xie wrote: Can't run a simple program. What's wrong, GC? import std.stdio; import std.date; void f0() { wstring a[]; foreach(i; 0 .. 100_000_000) { a ~= " "w; } } void main() { auto r = benchmark!(f0)(1);

Re: Memory allocation faile on string concat

2010-11-10 Thread Steven Schveighoffer
On Wed, 10 Nov 2010 13:33:11 -0500, Steven Schveighoffer wrote: On Wed, 10 Nov 2010 11:33:45 -0500, Xie wrote: Can't run a simple program. What's wrong, GC? import std.stdio; import std.date; void f0() { wstring a[]; foreach(i; 0 .. 100_000_000) {

Re: ponce

2010-11-10 Thread Steven Schveighoffer
On Wed, 10 Nov 2010 13:08:10 -0500, Jonathan M Davis wrote: On Wednesday, November 10, 2010 07:55:42 Steven Schveighoffer wrote: Pardon my ignorance, but how can something evaluated at compile time go on the heap? The heap doesn't exist yet! e.g.: class C { int[] buffer; this()

Re: Memory allocation faile on string concat

2010-11-10 Thread Steven Schveighoffer
On Wed, 10 Nov 2010 11:33:45 -0500, Xie wrote: Can't run a simple program. What's wrong, GC? import std.stdio; import std.date; void f0() { wstring a[]; foreach(i; 0 .. 100_000_000) { a ~= " "w; } } void main() { auto r = benchmark!(f0

Re: Memory allocation faile on string concat

2010-11-10 Thread Jonathan M Davis
On Wednesday, November 10, 2010 08:33:45 Xie wrote: > Can't run a simple program. What's wrong, GC? > > import std.stdio; > import std.date; > > void f0() > { > wstring a[]; > > foreach(i; 0 .. 100_000_000) > { > a ~= " "w; > } > } > > void main() > { >

Re: 2 bool optional params

2010-11-10 Thread Jonathan M Davis
On Wednesday, November 10, 2010 06:16:05 spir wrote: > On Wed, 10 Nov 2010 00:30:55 -0800 > > Jonathan M Davis wrote: > > On Tuesday 09 November 2010 23:55:26 spir wrote: > > > Hello, > > > > > > Is there a way for a func to hold 2 optional params of the same type? > > > > > > void f(int p, b

Re: ponce

2010-11-10 Thread Jonathan M Davis
On Wednesday, November 10, 2010 07:55:42 Steven Schveighoffer wrote: > On Tue, 09 Nov 2010 17:14:33 -0500, Don wrote: > > bearophile wrote: > >> Jonathan M Davis: > >>> it would be possible to make it so that any objects allocated with new > >>> during CTFE would be in the dynamic heap during runt

Re: Converting Fuse headers

2010-11-10 Thread div0
On 10/11/2010 06:21, Jesse Phillips wrote: I have some good news! It works (Simplest test case). I spent several hours trying to track down where my code translation could be causing problems. And have concluded that core.sys.posix.sys.stat.stat_t is not correct for my 32bit Debian Linux machi

Re: 2 bool optional params

2010-11-10 Thread spir
On Wed, 10 Nov 2010 11:03:27 -0500 "Steven Schveighoffer" wrote: > On Wed, 10 Nov 2010 09:16:05 -0500, spir wrote: > > > On Wed, 10 Nov 2010 00:30:55 -0800 > > Jonathan M Davis wrote: > > > >> On Tuesday 09 November 2010 23:55:26 spir wrote: > >> > Hello, > >> > > >> > Is there a way for a fun

Memory allocation faile on string concat

2010-11-10 Thread Xie
Can't run a simple program. What's wrong, GC? import std.stdio; import std.date; void f0() { wstring a[]; foreach(i; 0 .. 100_000_000) { a ~= " "w; } } void main() { auto r = benchmark!(f0)(1); writeln(r, "ms"); } DMD 2.047

Re: 2 bool optional params

2010-11-10 Thread Steven Schveighoffer
On Wed, 10 Nov 2010 09:16:05 -0500, spir wrote: On Wed, 10 Nov 2010 00:30:55 -0800 Jonathan M Davis wrote: On Tuesday 09 November 2010 23:55:26 spir wrote: > Hello, > > Is there a way for a func to hold 2 optional params of the same type? >void f(int p, bool b1=false, bool b2=false) { >

Re: ponce

2010-11-10 Thread Steven Schveighoffer
On Tue, 09 Nov 2010 17:14:33 -0500, Don wrote: bearophile wrote: Jonathan M Davis: it would be possible to make it so that any objects allocated with new during CTFE would be in the dynamic heap during runtime. This is possible, but it doesn't seem what you usually desire when you alloca

Re: 2 bool optional params

2010-11-10 Thread spir
On Wed, 10 Nov 2010 00:30:55 -0800 Jonathan M Davis wrote: > On Tuesday 09 November 2010 23:55:26 spir wrote: > > Hello, > > > > Is there a way for a func to hold 2 optional params of the same type? > > void f(int p, bool b1=false, bool b2=false) { > > writefln("p=%s b1=%s b2=%s", p,

Re: 2 bool optional params

2010-11-10 Thread spir
On Wed, 10 Nov 2010 08:54:20 + (UTC) "Lars T. Kyllingstad" wrote: > On Wed, 10 Nov 2010 08:55:26 +0100, spir wrote: > > > Hello, > > > > Is there a way for a func to hold 2 optional params of the same type? > > void f(int p, bool b1=false, bool b2=false) { > > writefln("p=%s b1=

Re: ponce

2010-11-10 Thread Steven Schveighoffer
On Tue, 09 Nov 2010 15:42:06 -0500, bearophile wrote: Don: Yes. The rules will be: * no globals (same as pure). * no unsafe features (eg, no asm). * source code must be available. Everything else should work. If a class is instantiated at compile-time the memory of its instance goes in

segfault

2010-11-10 Thread spir
Hello D programmers, I'm blocked by a mysterious segfault I seem to be unable to diagnose. There is probably some point of D I have not yet understood. Below relevant piece of code; "***" marks debug instructions. The constructor works fine, assertions pass, and writeln writes: ([0-9]+ ("+

Re: 2 bool optional params

2010-11-10 Thread Lars T. Kyllingstad
On Wed, 10 Nov 2010 08:55:26 +0100, spir wrote: > Hello, > > Is there a way for a func to hold 2 optional params of the same type? > void f(int p, bool b1=false, bool b2=false) { > writefln("p=%s b1=%s b2=%s", p,b1,b2); >} > Or is there a workaroud? I'm not sure I underst

Re: std.json

2010-11-10 Thread Bob Cowdery
To answer my own question 'value.object["mode"].str' gets me there. bob On 09/11/2010 21:12, Bob Cowdery wrote: > Hi > > I'm trying to decode some json using std.json. I have figured out how to > get at primitives out but can't get to a dictionary object. > > If I send something like {"mode":"a

Re: 2 bool optional params

2010-11-10 Thread Jonathan M Davis
On Tuesday 09 November 2010 23:55:26 spir wrote: > Hello, > > Is there a way for a func to hold 2 optional params of the same type? > void f(int p, bool b1=false, bool b2=false) { > writefln("p=%s b1=%s b2=%s", p,b1,b2); >} > Or is there a workaroud? Try compiling it. It w