Re: Wrong const attribute?

2011-09-23 Thread Christophe
Paolo Invernizzi , dans le message (digitalmars.D.learn:29680), a écrit : --Apple-Mail-7--919646864 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi all,=20 I've found nothing on bugzilla for that, what I'm missing? Or it's a = bug? (DMD

why global immutable string variable cannot be used after case?

2011-09-23 Thread Cheng Wei
import std.stdio; immutable HELLO = hello; void main() { auto string = hello; switch(string) { case HELLO: writeln(hello); break; default: writeln(unknown); break; } } testCase.d(7): Error: case must be a

Re: why global immutable string variable cannot be used after case?

2011-09-23 Thread Tobias Pankrath
If immutable cannot be used, what else can be used to replace #define in C? Thanks a lot. immutables are runtime constants. For case you need a compile time constant, which you can define with enum. enum string mycase = value;

Re: Wrong const attribute?

2011-09-23 Thread Paolo Invernizzi
Thank you all very much. Paolo On Sep 22, 2011, at 7:12 PM, Jonathan M Davis wrote: On Thursday, September 22, 2011 04:12 Paolo Invernizzi wrote: The error is a bit confusing but essentially correct. Bar has an immutable member variable. Once it's been initialized, that immutable member

Re: Using pure to create immutable

2011-09-23 Thread Daniel Murphy
Jesse Phillips jessekphillip...@gmail.com wrote in message news:j5gfsa$2d5g$1...@digitalmars.com... Thank you this lets it compile. I think I had that somewhere, but forgot about it. As Steve mentions, it probably should also work for const arguments too. It probably will, eventually. Some

Re: Using pure to create immutable

2011-09-23 Thread Regan Heath
On Thu, 22 Sep 2011 22:18:29 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 14:10 Steven Schveighoffer wrote: No, the parameter types can be const, and can accept mutable arguments. The main point is, the return value has to be proven to be *unique*. The

Re: why global immutable string variable cannot be used after case?

2011-09-23 Thread Jonathan M Davis
On Friday, September 23, 2011 01:38 Tobias Pankrath wrote: If immutable cannot be used, what else can be used to replace #define in C? Thanks a lot. immutables are runtime constants. For case you need a compile time constant, which you can define with enum. enum string mycase =

const overload

2011-09-23 Thread so
Hello everyone. I asked this a few times with no response. Could anyone explain me what is the rational behind this? Why it won't distinguish mutable overload from immutable as in C++? test2.d Description: Binary data

Re: const overload

2011-09-23 Thread Jonathan M Davis
On Friday, September 23, 2011 23:19:15 so wrote: Hello everyone. I asked this a few times with no response. Could anyone explain me what is the rational behind this? Why it won't distinguish mutable overload from immutable as in C++? That compiles fine with the lastest dmd from git. Is it

Re: const overload

2011-09-23 Thread Steven Schveighoffer
On Fri, 23 Sep 2011 16:19:15 -0400, so s...@so.so wrote: Hello everyone. I asked this a few times with no response. Could anyone explain me what is the rational behind this? Why it won't distinguish mutable overload from immutable as in C++? example? I'm afraid I don't really understand the

Global runtime strings help

2011-09-23 Thread Jonathan Crapuchettes
I'm working on an application that requires a large number of strings that only need to be loaded once at runtime and need to be accessible to all threads throughout the execution of the program. Some of these strings are variables like database host and username that need to be read from a

Re: Global runtime strings help

2011-09-23 Thread Jonathan M Davis
On Friday, September 23, 2011 13:29:08 Jonathan Crapuchettes wrote: I'm working on an application that requires a large number of strings that only need to be loaded once at runtime and need to be accessible to all threads throughout the execution of the program. Some of these strings are

Re: const overload

2011-09-23 Thread so
On Fri, 23 Sep 2011 23:27:02 +0300, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, September 23, 2011 23:19:15 so wrote: Hello everyone. I asked this a few times with no response. Could anyone explain me what is the rational behind this? Why it won't distinguish mutable overload

Re: const overload

2011-09-23 Thread Steven Schveighoffer
On Fri, 23 Sep 2011 16:27:23 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Fri, 23 Sep 2011 16:19:15 -0400, so s...@so.so wrote: Hello everyone. I asked this a few times with no response. Could anyone explain me what is the rational behind this? Why it won't distinguish mutable

Re: const overload

2011-09-23 Thread Steven Schveighoffer
On Fri, 23 Sep 2011 16:35:59 -0400, so s...@so.so wrote: On Fri, 23 Sep 2011 23:27:02 +0300, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, September 23, 2011 23:19:15 so wrote: Hello everyone. I asked this a few times with no response. Could anyone explain me what is the rational

Re: const overload

2011-09-23 Thread so
On Fri, 23 Sep 2011 23:44:52 +0300, Steven Schveighoffer schvei...@yahoo.com wrote: steves@steve-laptop:~/testd$ cat testconst.cpp #include iostream using namespace std; struct S { S fun() { cout fun endl; return *this; } S fun() const { cout

Re: const overload

2011-09-23 Thread so
On Fri, 23 Sep 2011 23:44:41 +0300, Jonathan M Davis jmdavisp...@gmx.com wrote: It uses the const version if the struct or class is const. And in neither case in your program is it const. It's mutable in both, so the mutable overload is the one that gets called in both places. Why would

Re: Conditional Compilation with Version

2011-09-23 Thread alex
O... So I if it is in my main function (which I think it is) I should move it out? That makes sense... Thank you Timon!!

Multithreaded file IO?

2011-09-23 Thread Jerry Quinn
Hi folks, I wasn't sure whether this should go here or in the D devel list... I'm trying to port a program where threads read from a file, process the data, then write the output data. The program is cpu-bound. In C++ I can do something like this: class QueueIn { ifstream in; mutex m;

Re: Multithreaded file IO?

2011-09-23 Thread Jonathan M Davis
On Friday, September 23, 2011 23:01:17 Jerry Quinn wrote: Hi folks, I wasn't sure whether this should go here or in the D devel list... I'm trying to port a program where threads read from a file, process the data, then write the output data. The program is cpu-bound. In C++ I can do

Re: Multithreaded file IO?

2011-09-23 Thread Jerry Quinn
Jonathan M Davis Wrote: On Friday, September 23, 2011 23:01:17 Jerry Quinn wrote: A direct rewrite would involve using shared and synchronized (either on the class or a synchronized block around the code that you want to lock). However, the more idiomatic way to do it would be to use