Re: Trying to compile sample from The D Programming Language book.

2011-04-04 Thread Jesus Alvarez
I reported the error to the author. Thanks guys! On Sun, Apr 3, 2011 at 3:34 AM, spir denis.s...@gmail.com wrote: On 04/03/2011 09:38 AM, Jesus Alvarez wrote: I got it to compile adding std.regex to split to make it: auto words = std.regex.split (sentence, regex([ \t,.;:?]+)); So now my

Re: How to check if an array is a manifest constant?

2011-04-04 Thread simendsjo
But there is a difference in how they behave, and I have no way of checking this behavior. Consider the following little snippet: void f(int[] a) { a[0] = -1; } void main() { int[] a = [1,2,3]; static assert(is(typeof(a) == int[])); f(a); assert(a[0] == -1); // a passed by

Re: How to check if an array is a manifest constant?

2011-04-04 Thread Jonathan M Davis
On 2011-04-04 01:16, simendsjo wrote: But there is a difference in how they behave, and I have no way of checking this behavior. Consider the following little snippet: void f(int[] a) { a[0] = -1; } void main() { int[] a = [1,2,3]; static assert(is(typeof(a) == int[]));

Re: How to check if an array is a manifest constant?

2011-04-04 Thread simendsjo
What use case do you have for wanting to know whether a variable is an enum or not? The same reason I'd like to check if it's const/immutable; if an algorithm requires a modifiable array. void sortInPlace(int[] array) { array.sort; } void main() { int[] a = [3,2,1];

Re: Static array size limit

2011-04-04 Thread Steven Schveighoffer
On Sat, 02 Apr 2011 10:45:51 -0400, bearophile bearophileh...@lycos.com wrote: simendsjo: http://digitalmars.com/d/2.0/arrays.html says static arrays are limited to 16mb, but I can only allocate 1mb. My fault, or bug? It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof =

Re: Array slices and copy on write

2011-04-04 Thread Steven Schveighoffer
On Sun, 03 Apr 2011 08:29:47 -0400, simendsjo simen.end...@pandavre.com wrote: D will copy the original content if a slice expands, but is the following behavior implementation specific, or part of the specification? auto a = [0,1,2]; auto b = a[0..2]; a.length = 2;

Re: How to spawn processes while keeping the parent process open ?

2011-04-04 Thread Kai Meyer
On 04/03/2011 07:31 AM, Tarun Ramakrishna wrote: Hi, Apparently std.process.exec (D2.052/windows) doesn't work the way the documentation describes. It terminates the parent process. Is there a way to keep the parent process open in D ? I also vaguely remember seeing some mails on this list

Re: Array operation doesn't check array bounds

2011-04-04 Thread Kai Meyer
On 04/03/2011 05:06 PM, Jonathan M Davis wrote: On 2011-04-03 04:10, simendsjo wrote: int[] a = [1,2,3]; int[4] b; assert(b == [0,0,0,0]); b = a[] * 3; // oops... a[] * 3 takes element outside a's bounds assert(b[$-1] == 0); // fails.. last element is

Re: Static array size limit

2011-04-04 Thread bearophile
Steven Schveighoffer: That would be 16 MiB. http://en.wikipedia.org/wiki/Mebibyte Then I think 16 MiB are more useful than 16_000_000 bytes. Bye, bearophile

Re: Static array size limit

2011-04-04 Thread Steven Schveighoffer
On Mon, 04 Apr 2011 12:43:03 -0400, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: That would be 16 MiB. http://en.wikipedia.org/wiki/Mebibyte Then I think 16 MiB are more useful than 16_000_000 bytes. Seems arbitrary to me. I'm sure some people feel 32MB would be

Re: How to spawn processes while keeping the parent process open ?

2011-04-04 Thread Tarun Ramakrishna
Hi Kai, Thanks. Yes, I came to realize that myself. Since I didn't see a fork in std.process, I assumed it was different from the POSIX semantics. Thanks, Tarun On Mon, Apr 4, 2011 at 8:32 PM, Kai Meyer k...@unixlords.com wrote: On 04/03/2011 07:31 AM, Tarun Ramakrishna wrote: Hi,

Re: Array slices and copy on write

2011-04-04 Thread Steven Schveighoffer
On Mon, 04 Apr 2011 14:30:34 -0400, simendsjo simen.end...@pandavre.com wrote: On 04.04.2011 15:53, Steven Schveighoffer wrote: 2. The D GC collects entire memory blocks, not portions of them. There is no way for the GC to collect a[3]. It can only collect the entire memory block which

Re: Is there an equivalent to toStringz for wide strings?

2011-04-04 Thread Jonathan M Davis
On 2011-04-04 16:17, Andrej Mitrovic wrote: I think I'd need a toWStringz function, or maybe toStringz can be made more clever and figure out that I'm passing a wstring and return a null-terminated wchar*. Currently I'm using wstrings and appending the null terminator by hand, e.g.:

Re: Is there an equivalent to toStringz for wide strings?

2011-04-04 Thread Andrej Mitrovic
On 4/5/11, Jonathan M Davis jmdavisp...@gmx.com wrote: Not to mention, in the case above, a null character should automatically be appended onto the end of the string, since it's as string literal. I've always found this confusing. So If I have this char array: char[] foostring = foo.dup;

Re: Is there an equivalent to toStringz for wide strings?

2011-04-04 Thread Jonathan M Davis
On 2011-04-04 16:44, Andrej Mitrovic wrote: On 4/5/11, Jonathan M Davis jmdavisp...@gmx.com wrote: Not to mention, in the case above, a null character should automatically be appended onto the end of the string, since it's as string literal. I've always found this confusing. So If I have

Re: Is there an equivalent to toStringz for wide strings?

2011-04-04 Thread Andrej Mitrovic
Ok that makes sense. Thank you.

Re: Using opDispatch as *magic* getter/setter. Possible or not?

2011-04-04 Thread Simen kjaeraas
On Thu, 31 Mar 2011 02:32:35 +0200, Aleksandar Ružičić ruzicic.aleksan...@gmail.com wrote: Is it possible to use opDispatch as generic getter and setter at the same time? Something like __get() and __set() in PHP.. this is what I've tried: https://gist.github.com/895571 and I get Error: