Re: Object Serialization?

2012-04-25 Thread Jacob Carlborg
On 2012-04-24 23:30, sclytrack wrote: Does it automatically pick everything to serialize? Yes. How would you make it more selective? It depends on what you want to do. struct Me { int x; int y; } serialize x but not y. In this simple case you can do like this: struct Me { int x;

Help with C struct by value on OSX 64bits

2012-04-25 Thread Johan Hernandez
Hi. I'm having trouble calling a C function passing a structure by value, printing a member and getting it back in D but I must be doing something wrong. I have a C file called native.c that defines a function called 'filter' taking a buf_t structure, I compile it using GCC to native.o. From

Strange measurements when reproducing issue 5650

2012-04-25 Thread SomeDude
Discussion here: http://d.puremagic.com/issues/show_bug.cgi?id=5650 On my Windows box, the following program import std.stdio, std.container, std.range; void main() { enum int range = 100; enum int n = 1_000_000; auto t = redBlackTree!int(0); for (int i = 0; i < n; i++) {

Re: Help with C struct by value on OSX 64bits

2012-04-25 Thread simendsjo
On Wed, 25 Apr 2012 09:57:39 +0200, Johan Hernandez wrote: Hi. I'm having trouble calling a C function passing a structure by value, printing a member and getting it back in D but I must be doing something wrong. Could be this one: http://d.puremagic.com/issues/show_bug.cgi?id=5570

newb question re. reading lines from stdin

2012-04-25 Thread aylwyn
Hi, I've just written a smallish program reading lines from stdin and doing some parsing and other text processing. I find it's about 3-4 times faster than a python script I had doing the same thing, which is nice but not as good as I hoped. After profiling, it seems almost half the total time is

Re: newb question re. reading lines from stdin

2012-04-25 Thread Dmitry Olshansky
On 25.04.2012 15:10, aylwyn wrote: Hi, I've just written a smallish program reading lines from stdin and doing some parsing and other text processing. I find it's about 3-4 times faster than a python script I had doing the same thing, which is nice but not as good as I hoped. After profiling, it

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 21/04/2012 19:24, H. S. Teoh wrote: In finished code, it's obviously a bad thing to have unused variables (unless the compiler optimizes them away, Whether the compiler optimises it away or not, an unused variable is a code smell. Complaining about unused variables serves as a warning to t

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread SomeDude
On Wednesday, 25 April 2012 at 08:34:40 UTC, SomeDude wrote: Noone reproduces this ?

Re: Docs: Section on local variables

2012-04-25 Thread simendsjo
On Wed, 25 Apr 2012 13:30:09 +0200, Stewart Gordon wrote: On 21/04/2012 17:26, Andrej Mitrovic wrote: Next thing you know the compiler will start warning me when I indent my code with uneven number of spaces! Or more usefully, warn if you have a mishmash of tab and space indentation.

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 21/04/2012 17:26, Andrej Mitrovic wrote: Next thing you know the compiler will start warning me when I indent my code with uneven number of spaces! Or more usefully, warn if you have a mishmash of tab and space indentation. How do indent-sensitive languages (Haskell, Python, whatever else)

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread Martin Drašar
Dne 25.4.2012 13:27, SomeDude napsal(a): On Wednesday, 25 April 2012 at 08:34:40 UTC, SomeDude wrote: Noone reproduces this ? Linux uriel 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux DMD64 D Compiler v2.058 Commented writeln on average (10 runs) 40 ms slower. So yes,

Internal error: ..\ztc\cod3.c 485

2012-04-25 Thread Era Scarecrow
This is an interesting one that has cropped up. I'm curious if this is because the differences between a fixed/dynamic arrays. Working around it is easy enough but that it even does it is an annoyance. I'm not seeing this exact problem in the archives, and I am not sure if it's in the t

Re: Internal error: ..\ztc\cod3.c 485

2012-04-25 Thread Steven Schveighoffer
http://d.puremagic.com/issues/show_bug.cgi?id=7254 maybe? -Steve

Re: A "general" tag

2012-04-25 Thread Marco Leise
Am Mon, 16 Apr 2012 20:52:16 +0200 schrieb "Xan" : > Uf!, it's more than I can process > It's really a **complicated** thing to do that in D. Too much information, yes. Too complicated no. :) D is statically typed (Fantom allows both static and dynamic typing). That means that for every vari

D static lib called from C on Mac OS X

2012-04-25 Thread Nicolas Sicard
Hi, I am trying to use a D static library from C on Mac OSX Lion, but it always fails. --- file mylib.d --- module mylib; import core.runtime; extern(C) { bool mylib_init() { return Runtime.initialize(); } bool mylib_free() { re

Re: D static lib called from C on Mac OS X

2012-04-25 Thread Nicolas Sicard
s/void/int in main.c

Bitarray size limits

2012-04-25 Thread ixid
These seem to be limited to uint.max length. Is there a way to make larger bit arrays?

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread Don Clugston
On 25/04/12 10:34, SomeDude wrote: Discussion here: http://d.puremagic.com/issues/show_bug.cgi?id=5650 On my Windows box, the following program import std.stdio, std.container, std.range; void main() { enum int range = 100; enum int n = 1_000_000; auto t = redBlackTree!int(0); for (int i = 0

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread Steven Schveighoffer
On Wed, 25 Apr 2012 07:27:29 -0400, SomeDude wrote: On Wednesday, 25 April 2012 at 08:34:40 UTC, SomeDude wrote: Noone reproduces this ? On my linux box, it runs in about 580ms, with or without the writeln. This is what I would expect. But things can be strange when dealing with GC timin

Re: Range of random numbers

2012-04-25 Thread Christophe Travert
"bearophile" , dans le message (digitalmars.D.learn:35148), a écrit : > Why don't you write a little benchmark to compare the performance > of the two versions? Because I'm interested in the code's meaning for the human reader, not the performance. I actually think : "map!(_=> uniform(a, b))(re

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread Jordi Sayol
Al 25/04/12 13:27, En/na SomeDude ha escrit: > On Wednesday, 25 April 2012 at 08:34:40 UTC, SomeDude wrote: > > Noone reproduces this ? > My results in Linux: 32-bit executable: About 574ms, with or without writeln. 64-bit executable: About 798ms, with or without writeln. -- Jordi Sayol

Re: Issue calling methods using std.concurrency

2012-04-25 Thread Casey
Stanislav: I think you just hit the nail on the head with the shared reference to this. I didn't even think of that as the error message made me think of the parameter being shared. As for solving it, I'll have to think about it. I was hoping to just have a single queue class (Or any other i

Re: Bitarray size limits

2012-04-25 Thread bearophile
ixid: These seem to be limited to uint.max length. Is there a way to make larger bit arrays? Yeah, fixing the BigArray source :-) It's limited by size_t.max length, that equals to uint.max on 32 bit systems. It contains code like: struct BitArray { size_t len; size_t* ptr; @pr

ptrace (process trace system call) on Linux from D

2012-04-25 Thread Matej Nanut
Hello everyone, I would like to know how to call ptrace (the system call) from D. I don't know what to import or link. If my understanding is correct, I need to create a .di file of some sort with stuff declared in it. How would I do this? Thanks, Matej

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread SomeDude
On Wednesday, 25 April 2012 at 15:35:44 UTC, Steven Schveighoffer wrote: On Wed, 25 Apr 2012 07:27:29 -0400, SomeDude wrote: On Wednesday, 25 April 2012 at 08:34:40 UTC, SomeDude wrote: Noone reproduces this ? On my linux box, it runs in about 580ms, with or without the writeln. This is

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread Marco Leise
Am Wed, 25 Apr 2012 10:34:38 +0200 schrieb "SomeDude" : > Discussion here: > http://d.puremagic.com/issues/show_bug.cgi?id=5650 > > On my Windows box, the following program > > import std.stdio, std.container, std.range; > > void main() { > enum int range = 100; > enum int n = 1_000_

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread Steven Schveighoffer
On Wed, 25 Apr 2012 13:05:59 -0400, SomeDude wrote: On Wednesday, 25 April 2012 at 15:35:44 UTC, Steven Schveighoffer wrote: On Wed, 25 Apr 2012 07:27:29 -0400, SomeDude wrote: On Wednesday, 25 April 2012 at 08:34:40 UTC, SomeDude wrote: Noone reproduces this ? On my linux box, it ru

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread SomeDude
On Wednesday, 25 April 2012 at 17:06:00 UTC, SomeDude wrote: On Wednesday, 25 April 2012 at 15:35:44 UTC, Steven Schveighoffer wrote: On Wed, 25 Apr 2012 07:27:29 -0400, SomeDude wrote: On Wednesday, 25 April 2012 at 08:34:40 UTC, SomeDude wrote: Noone reproduces this ? On my linux box, i

Re: D static lib called from C on Mac OS X

2012-04-25 Thread Nicolas Sicard
More testing. This: --- file mylib.d module mylib; import core.runtime; import std.stdio; extern(C) { bool mylib_init() { return Runtime.initialize(); } bool mylib_free() { return Runtime.terminate(); } void mylib_

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread H. S. Teoh
On Wed, Apr 25, 2012 at 10:34:38AM +0200, SomeDude wrote: [...] > import std.stdio, std.container, std.range; > > void main() { > enum int range = 100; > enum int n = 1_000_000; > > auto t = redBlackTree!int(0); > > for (int i = 0; i < n; i++) { > if (i > range) >

Power of D

2012-04-25 Thread bioinfornatics
i search some example of something easy (more easy) to do in D an not in another language if possible - D - C++ - D - Haskell - D - Java - D - python thanks a lot

Re: Docs: Section on local variables

2012-04-25 Thread Andrej Mitrovic
On 4/25/12, Stewart Gordon wrote: > Even if it's left over from debugging, it > looks silly, and > might lead other people reading the code to believe something's wrong. There's about a million ways to make code unreadable, and nobody writes pitch-perfect code that has absolutely no leftover code

Re: D static lib called from C on Mac OS X

2012-04-25 Thread Andrej Mitrovic
On 4/25/12, Nicolas Sicard wrote: > --- file main.c --- > extern void mylib_init(); > extern void mylib_free(); Try changing void to bool there.

Re: ptrace (process trace system call) on Linux from D

2012-04-25 Thread mta`chrono
Am 25.04.2012 18:36, schrieb Matej Nanut: > Hello everyone, > > I would like to know how to call ptrace (the system call) from D. > > I don't know what to import or link. If my understanding is correct, I > need to create a .di file of some sort with stuff declared in it. How > would I do this?

Re: D static lib called from C on Mac OS X

2012-04-25 Thread Nicolas Sicard
On Wednesday, 25 April 2012 at 17:59:38 UTC, Andrej Mitrovic wrote: On 4/25/12, Nicolas Sicard wrote: --- file main.c --- extern void mylib_init(); extern void mylib_free(); Try changing void to bool there. This was a typo in my first post. The problem is elsewhere. Thanks

[Kinda OT] httpd permissions

2012-04-25 Thread Nathan M. Swan
How do I deal with this (on OSX); are CGI programs not allowed to write to files? How to change this? Thanks, NMS test.d: #!/usr/local/bin/rdmd import std.stdio; void main() { writeln("Content-type: text/plain\r\n\r\nHello, World!"); } error log: [Wed Apr 25 00:03:01 2012] [error] [cli

Re: [Kinda OT] httpd permissions

2012-04-25 Thread Nicolas Sicard
On Wednesday, 25 April 2012 at 18:11:16 UTC, Nathan M. Swan wrote: How do I deal with this (on OSX); are CGI programs not allowed to write to files? How to change this? Thanks, NMS test.d: #!/usr/local/bin/rdmd import std.stdio; void main() { writeln("Content-type: text/plain\r\n\r\nH

Re: Help with C struct by value on OSX 64bits

2012-04-25 Thread Johan Hernandez
On Wednesday, 25 April 2012 at 08:38:02 UTC, simendsjo wrote: Could be this one: http://d.puremagic.com/issues/show_bug.cgi?id=5570 Thank you for your response. It's a huge issue :(

Why is List(T) documented in std.concurrency?

2012-04-25 Thread Alex Rønne Petersen
Hi, http://dlang.org/phobos/std_concurrency.html Why does List(T) appear? Isn't it private? -- - Alex

Using input ranges with std.regex?

2012-04-25 Thread H. S. Teoh
Does std.regex support input ranges to match()? Or do I need to convert to string first? Thanks! T -- Tell me and I forget. Teach me and I remember. Involve me and I understand. -- Benjamin Franklin

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 25/04/2012 17:10, Andrej Mitrovic wrote: On 4/25/12, Stewart Gordon wrote: Even if it's left over from debugging, it looks silly, and might lead other people reading the code to believe something's wrong. There's about a million ways to make code unreadable, and nobody writes pitch-perfect

Re: Help with C struct by value on OSX 64bits

2012-04-25 Thread simendsjo
On Wed, 25 Apr 2012 20:36:31 +0200, Johan Hernandez wrote: On Wednesday, 25 April 2012 at 08:38:02 UTC, simendsjo wrote: Could be this one: http://d.puremagic.com/issues/show_bug.cgi?id=5570 Thank you for your response. It's a huge issue :( I agree. Let's hope it gets fixed now that it'

Re: Help with C struct by value on OSX 64bits

2012-04-25 Thread Jacob Carlborg
On 2012-04-25 20:36, Johan Hernandez wrote: On Wednesday, 25 April 2012 at 08:38:02 UTC, simendsjo wrote: Could be this one: http://d.puremagic.com/issues/show_bug.cgi?id=5570 Thank you for your response. It's a huge issue :( Compile as a 32bit binary. For DMD add "-m32" do the flags. For g

Re: Why is List(T) documented in std.concurrency?

2012-04-25 Thread Jonathan M Davis
On Wednesday, April 25, 2012 21:00:33 Alex Rønne Petersen wrote: > Hi, > > http://dlang.org/phobos/std_concurrency.html > > Why does List(T) appear? Isn't it private? It's probably due to http://d.puremagic.com/issues/show_bug.cgi?id=2775 However, to make things weirder, it _doesn't_ have ddoc

Re: Docs: Section on local variables

2012-04-25 Thread Jonathan M Davis
On Wednesday, April 25, 2012 20:10:18 Stewart Gordon wrote: > On 25/04/2012 17:10, Andrej Mitrovic wrote: > > On 4/25/12, Stewart Gordon wrote: > >> Even if it's left over from debugging, it > >> looks silly, and > >> might lead other people reading the code to believe something's wrong. > > > > T

Re: Why is List(T) documented in std.concurrency?

2012-04-25 Thread Mirko Pilger
Since there's only one *, it shouldn't show up in the docs, even if it's public. "If there is no documentation comment for a declaration, that declaration may not appear in the output. To ensure it does appear in the output, put an empty declaration comment for it." http://dlang.org/ddoc.htm

Re: Docs: Section on local variables

2012-04-25 Thread Andrej Mitrovic
On 4/25/12, Stewart Gordon wrote: > So you think that > > import std.stdio; > void main() { > int a, b; > a + b; > return; > writefln("Hello, world!"); > } > > should generate no errors or warnings whatsoever? I'm really only talking about: void a() { int x; } And of course:

Re: Docs: Section on local variables

2012-04-25 Thread Andrej Mitrovic
On 4/25/12, Andrej Mitrovic wrote: > I'm really only talking about Although I'm not a fan of warnings for unused variables, I would be a fan of this: http://d.puremagic.com/issues/show_bug.cgi?id=3507 But again, other people might not like that. But if it was an option..

Re: Docs: Section on local variables

2012-04-25 Thread H. S. Teoh
On Wed, Apr 25, 2012 at 04:03:04PM -0400, Jonathan M Davis wrote: [...] > increasingly I agree with Walter's take on warnings (that they > shouldn't exist at all - something is an error or it isn't; none of > this halfway stuff). Warnings are problematic in that a good > programmer will _never_ lea

Re: Why is List(T) documented in std.concurrency?

2012-04-25 Thread Jonathan M Davis
On Wednesday, April 25, 2012 22:01:45 Mirko Pilger wrote: > > Since there's only one *, it shouldn't show up in the docs, even if it's > > public. > > "If there is no documentation comment for a declaration, that > declaration may not appear in the output. To ensure it does appear in > the output,

Re: Docs: Section on local variables

2012-04-25 Thread Jonathan M Davis
On Wednesday, April 25, 2012 22:12:02 Andrej Mitrovic wrote: > I'd like the warnings to be individually selectable, just like in GCC. Having sets of warnings that you can explicitly enable makes a lot of sense, because it enables the programmer to have the compiler warn about stuff that they car

Re: Using input ranges with std.regex?

2012-04-25 Thread Dmitry Olshansky
On 25.04.2012 23:08, H. S. Teoh wrote: Does std.regex support input ranges to match()? Or do I need to convert to string first? For now, yes you have to convert them. Any random access range of code units should do the trick but stringish template constraints might kill that. I plan to ext

Re: Docs: Section on local variables

2012-04-25 Thread Stewart Gordon
On 25/04/2012 21:12, Andrej Mitrovic wrote: I'm really only talking about: void a() { int x; } What is the distinction you're making exactly? And of course: void a() { bool state; ... if (state) { } } You mean an empty if body should trigger something? Or shouldn't? OK, so I can see a si

Re: Docs: Section on local variables

2012-04-25 Thread Andrej Mitrovic
On 4/25/12, Stewart Gordon wrote: > What is the distinction you're making exactly? > You mean an empty if body should trigger something? Or shouldn't? I'm saying those are exactly the cases presented in the docs and I don't want them to warn by default but have a setting. I mean, the first case

Re: Internal error: ..\ztc\cod3.c 485

2012-04-25 Thread Era Scarecrow
On Wednesday, 25 April 2012 at 12:43:39 UTC, Steven Schveighoffer wrote: http://d.puremagic.com/issues/show_bug.cgi?id=7254 maybe? Maybe... but it shouldn't be the wrong return; at least being a static length known at compile-time should convert to char[4]. I'm not sure how try/catch would m

OT: Indent-sensitive languages again (was: Docs: Section on local variables)

2012-04-25 Thread Stewart Gordon
On 25/04/2012 12:30, Stewart Gordon wrote: On 21/04/2012 17:26, Andrej Mitrovic wrote: Next thing you know the compiler will start warning me when I indent my code with uneven number of spaces! Or more usefully, warn if you have a mishmash of tab and space indentation. How do indent-sensitiv

Re: Why is List(T) documented in std.concurrency?

2012-04-25 Thread Ali Çehreli
On 04/25/2012 02:15 PM, Jonathan M Davis wrote: On Wednesday, April 25, 2012 22:01:45 Mirko Pilger wrote: Since there's only one *, it shouldn't show up in the docs, even if it's public. "If there is no documentation comment for a declaration, that declaration may not appear in the output. To

Re: Power of D

2012-04-25 Thread Ary Manzana
On 4/26/12 1:51 AM, bioinfornatics wrote: i search some example of something easy (more easy) to do in D an not in another language if possible - D - C++ ... - D - Haskell - D - Java - D - python A segmentation fault is really easy to do in D but hard in those languages. :-P

Pointer to variables in D

2012-04-25 Thread Victor Vicente de Carvalho
Hi there, In c++ one can access a pointer to a class/struct variable using this semantic: struct C { int x; }; int C::* ptr = &C::x; C foo; foo.*ptr = 10; assert(foo.x == 10); It is possible to do something like that on D? I've searched through the forum & documentation but didn't found

Re: Why is List(T) documented in std.concurrency?

2012-04-25 Thread Jonathan M Davis
On Wednesday, April 25, 2012 17:31:29 Ali Çehreli wrote: > On 04/25/2012 02:15 PM, Jonathan M Davis wrote: > > On Wednesday, April 25, 2012 22:01:45 Mirko Pilger wrote: > >>> Since there's only one *, it shouldn't show up in the docs, even if it's > >>> public. > >> > >> "If there is no documentat

Re: [Kinda OT] httpd permissions

2012-04-25 Thread Nathan M. Swan
Have you checked that your web server has write access to /Users/nathanmswan/Sites/ ? Yes, it works now, thanks! NMS P.S. Sorry this might be in the wrong forum, but now I can advertise my homepage as "index.d" instead of compiling it and having it be "index.cgi"

Re: Pointer to variables in D

2012-04-25 Thread Nathan M. Swan
On Thursday, 26 April 2012 at 02:43:35 UTC, Victor Vicente de Carvalho wrote: Hi there, In c++ one can access a pointer to a class/struct variable using this semantic: struct C { int x; }; int C::* ptr = &C::x; C foo; foo.*ptr = 10; assert(foo.x == 10); It is possible to do something lik

Re: Bitarray size limits

2012-04-25 Thread ixid
Thank you, I will have a play with that.

Re: Pointer to variables in D

2012-04-25 Thread EraScarecrow
On Thursday, 26 April 2012 at 03:54:25 UTC, Nathan M. Swan wrote: Yes. My rule: don't use pointers unless doing it otherwise is really slow or really hard. Might be safe to use a pointer on an immutable struct (Say, globally accessible data?). I'm trying this; but it's only to get around the

Re: Pointer to variables in D

2012-04-25 Thread H. S. Teoh
On Thu, Apr 26, 2012 at 06:57:50AM +0200, EraScarecrow wrote: > On Thursday, 26 April 2012 at 03:54:25 UTC, Nathan M. Swan wrote: > >Yes. My rule: don't use pointers unless doing it otherwise is > >really slow or really hard. > > Might be safe to use a pointer on an immutable struct (Say, > globa

Re: Pointer to variables in D

2012-04-25 Thread Era Scarecrow
On Thursday, 26 April 2012 at 05:16:51 UTC, H. S. Teoh wrote: Besides, D's auto-deferencing semantics on pointers makes the difference barely noticeable anyway. Pointers auto-deference when using '.' member notation, for example. Once in a while you have to explicitly dereference a pointer or

Re: Power of D

2012-04-25 Thread Era Scarecrow
On Wednesday, 25 April 2012 at 17:52:36 UTC, bioinfornatics wrote: i search some example of something easy (more easy) to do in D an not in another language if possible - D - C++ - D - Haskell - D - Java - D - python thanks a lot Associative arrays? C++: #include #include map m; Java:

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-25 Thread Marco Leise
Am Sun, 22 Apr 2012 09:23:45 +0200 schrieb "Jay Norwood" : > On Sunday, 22 April 2012 at 06:26:42 UTC, Jonathan M Davis wrote: > > > > You can look at the code. It checks each of the characters in > > place. Unlike > > toLower, it doesn't need to generate a new string. But as far > > as the > >

Re: Power of D

2012-04-25 Thread Jonathan M Davis
On Wednesday, April 25, 2012 19:51:18 bioinfornatics wrote: > i search some example of something easy (more easy) to do in D an not > in another language if possible > - D - C++ > - D - Haskell > - D - Java > - D - python > > thanks a lot Pretty much everything that Andrei talks about in this re

Re: What am I doing wrong ?

2012-04-25 Thread Marco Leise
Am Sun, 22 Apr 2012 23:47:20 +0200 schrieb "SomeDude" : > void main() { > auto array = new Foo[10]; > --> for(int i = array.length; i > 1; i--) { array[i].x = i; } > writeln(); > foreach(Foo f; array) { write(f.x);} > } > > throws core.exception.RangeError@bug(8): Range violation o