Re: Stack overflow

2012-06-24 Thread Namespace
Wait, you have a template mixin inside of Foo which passes Foo to it? I don't know if you can get away with that or not, since you're trying to pass a type to a template while you're adding stuff to it via that template. So, the type is incomplete. I'm willing to be that that's your problem, but

Re: Learning asynchronous sockets in D (well actually C...)

2012-06-24 Thread Jarl André
On Sunday, 24 June 2012 at 23:04:14 UTC, Sean Kelly wrote: On Jun 24, 2012, at 11:40 AM, "Jarl André" "@puremagic.com wrote: Is it wrong to badge myself with asynchronous sockets? :) Nope. It's pretty weird stuff if you've never done event-based programming before. I shouldn't glorify m

Problem about using struct

2012-06-24 Thread Tongzhou Li
Hello! I'm learning D, and wrote some sample codes with D. I wrote: http://ideone.com/VY7ES It failed to compile; I got 2 errors: main.d(19): Error: constructor main.carry!(int,int,int,int,int).carry.this (int delegate(int, int _param_0, int _param_1, int _param_2) _f) is not callable usin

Re: A little story

2012-06-24 Thread Tobias Pankrath
On Sunday, 24 June 2012 at 21:52:36 UTC, bearophile wrote: Just a recent little coding story. Maybe you should post this to the main newsgroup. I would prefer a switch that does this per scope, i.e: void foo() { pragma(check, int_overflow); // check only in this function }

Re: A little story

2012-06-24 Thread Jerome BENOIT
Thanks a lot for the explanation. Jerome On 25/06/12 02:54, bearophile wrote: Jerome BENOIT: How come as ``integral numbers (will not be) overflow'' ? Multiprecision numbers allocate on the heap when they become large (or they always allocate on the heap). This has a significant performance

Re: A little story

2012-06-24 Thread bearophile
Jerome BENOIT: How come as ``integral numbers (will not be) overflow'' ? Multiprecision numbers allocate on the heap when they become large (or they always allocate on the heap). This has a significant performance impact. There are many situations where Multiprecision numbers are handy, but

Re: Stack overflow

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 19:03:17 Namespace wrote: > > This might work: > > > > this(U)(U obj) > > > > if(is(U : T) && !is(U == typeof(null))) > > > > { > > } > > > > > > - Jonathan M Davis > > Interesting. With or wihtout that, if i add a method to Foo it > prints "Stack overflow" also.

Re: A little story

2012-06-24 Thread Jerome BENOIT
On 25/06/12 01:51, bearophile wrote: Jerome BENOIT: Is there any GMP port for D ? Jerome I don't know. (But GMP is NOT a solution to the problems shown in that story). How come as ``integral numbers (will not be) overflow'' ? Bye, bearophile

Re: A little story

2012-06-24 Thread bearophile
Jerome BENOIT: Is there any GMP port for D ? Jerome I don't know. (But GMP is NOT a solution to the problems shown in that story). Bye, bearophile

Re: about std.file.copy

2012-06-24 Thread bioinfornatics
Le dimanche 24 juin 2012 à 22:38 +0200, bioinfornatics a écrit : > Hi, > > I want to copy a file with executable mode (755 on UNIX) to another > location. when i use std.file.copy original is into 755 bot not the > copied file! > > The are a way to save the mode ? > > thanks > fixed by doing

Re: Learning asynchronous sockets in D (well actually C...)

2012-06-24 Thread Sean Kelly
On Jun 24, 2012, at 11:40 AM, "Jarl André" "@puremagic.com wrote: > > Is it wrong to badge myself with asynchronous sockets? :) Nope. It's pretty weird stuff if you've never done event-based programming before.

Re: A little story

2012-06-24 Thread Jerome BENOIT
On 24/06/12 23:52, bearophile wrote: And D is too much unsafe for such kind of programs, because integral numbers can silently overflow. Is there any GMP port for D ? Jerome

A little story

2012-06-24 Thread bearophile
Just a recent little coding story. Python is a good language for "exploratory programming", because the programs are succinct, it's flexible, its data structures are easy to use and good, there are already written modules to do most things, there are very easy to use libraries to plot results

Re: Learning asynchronous sockets in D (well actually C...)

2012-06-24 Thread Tobias Pankrath
The thing that developers should come from a C/C++ background is totally not acceptable. Yes. I also think the documentation shouldn't assume familiarity with C++. So we need to add a "Introduction to D for Java developers" etc, that makes it easier to start hacking right away. My question

about std.file.copy

2012-06-24 Thread bioinfornatics
Hi, I want to copy a file with executable mode (755 on UNIX) to another location. when i use std.file.copy original is into 755 bot not the copied file! The are a way to save the mode ? thanks

Re: Learning asynchronous sockets in D (well actually C...)

2012-06-24 Thread Jarl André
On Sunday, 24 June 2012 at 19:10:55 UTC, Tobias Pankrath wrote: * add -g and -debug=splat (or any other keywords) to the build command You don't need a keyword -debug is sufficient. To make the binary work with a debugger you does not even need -debug, only -g. -debug only includes code that

Re: Learning asynchronous sockets in D (well actually C...)

2012-06-24 Thread Tobias Pankrath
* add -g and -debug=splat (or any other keywords) to the build command You don't need a keyword -debug is sufficient. To make the binary work with a debugger you does not even need -debug, only -g. -debug only includes code that's in a debug-block. * gdb bin/SimpleServer * continue (on bre

Re: aa.remove in a destructor

2012-06-24 Thread Ellery Newcomer
On 06/24/2012 02:53 AM, Dmitry Olshansky wrote: I think no, as any with operation involving GC. For instance while you are removing elements table may decide to rehash itself and that means it may trigger allocation. okay, it looks like my [inherited] code is using aa's to map D objects to C

Re: Learning asynchronous sockets in D (well actually C...)

2012-06-24 Thread Jarl André
I have now completely and totally replaced the inner contents of my server library with modified Splat code. It ran so much faster that I was actually afraid I had got it wrong. It seemed not be any wrong with it, so adding Splat actually made it super kidding me fast. I have now learned a few

Re: std.json

2012-06-24 Thread Tim Shea
On Thursday, 17 May 2012 at 18:55:57 UTC, Jarl André wrote: On Thursday, 17 May 2012 at 18:36:22 UTC, Jarl André wrote: On Thursday, 17 May 2012 at 14:08:27 UTC, Vincent wrote: On Sunday, 25 March 2012 at 17:50:45 UTC, Andrea Fontana wrote: Hope it's clear... Nope, it's something like chess

Re: Stack overflow

2012-06-24 Thread Namespace
This might work: this(U)(U obj) if(is(U : T) && !is(U == typeof(null))) { } - Jonathan M Davis Interesting. With or wihtout that, if i add a method to Foo it prints "Stack overflow" also. http://dpaste.dzfl.pl/91dad66c Can you explain that?

Re: Retain struct when using alias this and passing using the alias..?

2012-06-24 Thread Tobias Pankrath
On Sunday, 24 June 2012 at 13:16:53 UTC, simendsjo wrote: import std.exception; import std.traits; struct Ranged(T, T min, T max) { T _value = min; typeof(this) opAssign(V : T)(V value) { enforce(value >= min); enforce(value <= max); _value = value; return

Re: Strange exception using threads

2012-06-24 Thread Sean Kelly
On Jun 23, 2012, at 9:31 AM, simendsjo wrote: > On Sat, 23 Jun 2012 18:29:37 +0200, simendsjo wrote: > >>auto tid = spawnLinked(&writer); > > auto tid = spawn(&writer); of course With spawnLinked the child will send a termination message to the parent as well.

Retain struct when using alias this and passing using the alias..?

2012-06-24 Thread simendsjo
import std.exception; import std.traits; struct Ranged(T, T min, T max) { T _value = min; typeof(this) opAssign(V : T)(V value) { enforce(value >= min); enforce(value <= max); _value = value; return this; } alias _value this; } void f(int i) {

Re: Stack overflow

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 14:57:37 Namespace wrote: > > My guess is that you've got something recursive going on > > (possibly a recursive > > template instantiation, though I don't see any reason why that > > would occur), > > which causes it to eat up more and more memory, until the OS > > kills i

Re: It is a bug or not?

2012-06-24 Thread bioinfornatics
On Sunday, 24 June 2012 at 11:59:07 UTC, bioinfornatics wrote: dear, A D user report to me that dbuilder fail to build i.e build log: http://pastebin.com/LaCn6ZxU The problem i have any problem to build the same code on *NIX then i tink it is a phobos bug to windows side, no ? i have try wi

Re: Stack overflow

2012-06-24 Thread Namespace
My guess is that you've got something recursive going on (possibly a recursive template instantiation, though I don't see any reason why that would occur), which causes it to eat up more and more memory, until the OS kills it. Report it as a dmd bug: http://d.puremagic.com - Jonathan M Davis

Re: AA with immutable values

2012-06-24 Thread Roman D. Boiko
On Sunday, 24 June 2012 at 12:34:28 UTC, Jonathan M Davis wrote: On Sunday, June 24, 2012 14:24:48 Roman D. Boiko wrote: Yeah, but I wonder that such a core feature as AA doesn't support this use case better (I mean more efficiently). The current AA implementation is quite buggy. It works, bu

Re: Stack overflow

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 14:29:10 Namespace wrote: > On Sunday, 24 June 2012 at 12:19:47 UTC, Jonathan M Davis wrote: > > On Sunday, June 24, 2012 14:09:38 Namespace wrote: > >> And can me now anybody explain why > >> @disable > >> this(typeof(null)); or any other ctor declaration prints "stack > >

Re: AA with immutable values

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 14:24:48 Roman D. Boiko wrote: > Yeah, but I wonder that such a core feature as AA doesn't support > this use case better (I mean more efficiently). The current AA implementation is quite buggy. It works, but there are all kinds of corner cases which it doesn't handle pro

Re: Stack overflow

2012-06-24 Thread Namespace
On Sunday, 24 June 2012 at 12:19:47 UTC, Jonathan M Davis wrote: On Sunday, June 24, 2012 14:09:38 Namespace wrote: And can me now anybody explain why @disable this(typeof(null)); or any other ctor declaration prints "stack overflow"? How it is possible, that one class and one struct kill the s

Re: AA with immutable values

2012-06-24 Thread Roman D. Boiko
On Sunday, 24 June 2012 at 12:21:50 UTC, Jonathan M Davis wrote: On Sunday, June 24, 2012 05:15:03 Ali Çehreli wrote: Although it sounds like a limitation, it may be due to the fact that AA may need to rehash, which may not be suitable with immutable values. const and immutable types as eleme

Re: AA with immutable values

2012-06-24 Thread Roman D. Boiko
On Sunday, 24 June 2012 at 12:15:10 UTC, Ali Çehreli wrote: Although it sounds like a limitation, it may be due to the fact that AA may need to rehash, which may not be suitable with immutable values. Thanks, now I can see the motivation. The following are two ways of generating immutable AA v

Re: AA with immutable values

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 05:15:03 Ali Çehreli wrote: > Although it sounds like a limitation, it may be due to the fact that AA > may need to rehash, which may not be suitable with immutable values. const and immutable types as elements of a container are problematic in general. The container gene

Re: Stack overflow

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 14:09:38 Namespace wrote: > And can me now anybody explain why > @disable > this(typeof(null)); or any other ctor declaration prints "stack > overflow"? > How it is possible, that one class and one struct kill the stack? Please provide a compilable example which exhibits t

Re: AA with immutable values

2012-06-24 Thread Ali Çehreli
On 06/24/2012 04:57 AM, Roman D. Boiko wrote: immutable(SomeClass)[S] _map; _map[S.init] = null; // doesn't compile since _map[S.init] is immutable My current workaround is: immutable(SomeClass)*[S] _map; _map[S.init] = [null].ptr; But this introduces an additional level of indirection in a per

Re: Stack overflow

2012-06-24 Thread Namespace
On Sunday, 24 June 2012 at 11:55:15 UTC, Jonathan M Davis wrote: On Sunday, June 24, 2012 11:35:46 Namespace wrote: > A non-nullable type _will_ be added to Phobos at some point. As struct or class or as built-in type? As I said, it will be added to _Phobos_. So, it will be a struct in the s

Re: AA with immutable values

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 13:57:44 Roman D. Boiko wrote: > immutable(SomeClass)[S] _map; > _map[S.init] = null; // doesn't compile since _map[S.init] is > immutable > > My current workaround is: > immutable(SomeClass)*[S] _map; > _map[S.init] = [null].ptr; > > But this introduces an additional lev

Re: Stack overflow

2012-06-24 Thread David
Am 24.06.2012 13:15, schrieb Timon Gehr: On 06/24/2012 12:37 PM, David wrote: Am 24.06.2012 11:35, schrieb Namespace: A non-nullable type _will_ be added to Phobos at some point. As struct or class or as built-in type? And can me explain somebody why [code] @disable this(typeof(null)); [/cod

AA with immutable values

2012-06-24 Thread Roman D. Boiko
immutable(SomeClass)[S] _map; _map[S.init] = null; // doesn't compile since _map[S.init] is immutable My current workaround is: immutable(SomeClass)*[S] _map; _map[S.init] = [null].ptr; But this introduces an additional level of indirection in a performance-critical part of my code. Probabl

Re: Stack overflow

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 11:35:46 Namespace wrote: > > A non-nullable type _will_ be added to Phobos at some point. > > As struct or class or as built-in type? As I said, it will be added to _Phobos_. So, it will be a struct in the standard library, not in the language itself. It'll probably be

Re: aa.remove in a destructor

2012-06-24 Thread Jonathan M Davis
On Sunday, June 24, 2012 11:53:37 Dmitry Olshansky wrote: > On 24-Jun-12 08:15, Ellery Newcomer wrote: > > this code: > > > > class X{ > > > > string[string] s; > > this() { > > > > s["s"] = "S"; > > > > } > > ~this() { > > > > s.remove("s")

Re: Stack overflow

2012-06-24 Thread Timon Gehr
On 06/24/2012 12:37 PM, David wrote: Am 24.06.2012 11:35, schrieb Namespace: A non-nullable type _will_ be added to Phobos at some point. As struct or class or as built-in type? And can me explain somebody why [code] @disable this(typeof(null)); [/code] print "Stack overflow"? What should

Re: Stack overflow

2012-06-24 Thread Namespace
On Sunday, 24 June 2012 at 10:37:39 UTC, David wrote: Am 24.06.2012 11:35, schrieb Namespace: A non-nullable type _will_ be added to Phobos at some point. As struct or class or as built-in type? And can me explain somebody why [code] @disable this(typeof(null)); [/code] print "Stack overflow"

Re: Stack overflow

2012-06-24 Thread David
Am 24.06.2012 11:35, schrieb Namespace: A non-nullable type _will_ be added to Phobos at some point. As struct or class or as built-in type? And can me explain somebody why [code] @disable this(typeof(null)); [/code] print "Stack overflow"? What should typeof(null) return you? void*, int*

Re: Stack overflow

2012-06-24 Thread Namespace
A non-nullable type _will_ be added to Phobos at some point. As struct or class or as built-in type? And can me explain somebody why [code] @disable this(typeof(null)); [/code] print "Stack overflow"?

Re: phobos and splitting things... but not with whitespace.

2012-06-24 Thread simendsjo
On Sun, 24 Jun 2012 10:02:07 +0200, Roman D. Boiko wrote: Just found a follow-up post: http://dblog.aldacron.net/2012/06/24/my-only-gripes-about-d/ Just found it myself. RSS for the win :) I can't say I disagree. You have to read through several modules to find what you need: std.string, s

Re: phobos and splitting things... but not with whitespace.

2012-06-24 Thread Roman D. Boiko
Just found a follow-up post: http://dblog.aldacron.net/2012/06/24/my-only-gripes-about-d/

Re: aa.remove in a destructor

2012-06-24 Thread Dmitry Olshansky
On 24-Jun-12 08:15, Ellery Newcomer wrote: this code: class X{ string[string] s; this() { s["s"] = "S"; } ~this() { s.remove("s"); } } void main() { X x = new X(); } produces this: core.exception.InvalidMemoryOperationError because the aa is c

Re: Passing a ubyte[] to a function taking a 'ref ubyte[16]'

2012-06-24 Thread Johannes Pfau
Am Sat, 23 Jun 2012 23:39:00 -0700 schrieb Ali Çehreli : > On 06/23/2012 04:51 PM, Jonathan M Davis wrote: > > >> This seems to work, but it's very ugly: > >> > >> _digest.finish(*cast(ubyte[16]*)buf.ptr); > >> > >> > >> I thought this might create a temporary, but

Re: Passing a ubyte[] to a function taking a 'ref ubyte[16]'

2012-06-24 Thread Johannes Pfau
Am Sat, 23 Jun 2012 16:51:14 -0700 schrieb Jonathan M Davis : > On Saturday, June 23, 2012 20:23:26 Johannes Pfau wrote: > > I'm working on the new design for std.hash and I hit an interesting > > problem: > > > > The OOP interface has to take buffers as slices with unknown > > length, as the len