Re: Auto keyword with const variable

2013-07-24 Thread bsd
On Wednesday, 24 July 2013 at 11:26:32 UTC, Mike Parker wrote: ... This is the exact behavior I would expect. I think of auto as "this variable is going to be the same type as that variable." Since in is const int, then j also is going to be const int. If you want to copy n into a nonconst vari

Re: Auto keyword with const variable

2013-07-24 Thread Jonathan M Davis
On Wednesday, July 24, 2013 10:07:54 Alex H wrote: > This code: > > void test(const int n) > { > auto j = n; > j++; > } > > Gives this error: > cannot modify const expression j > > > Is this considered a feature or a bug? I would assume most people > wouldn't want new variables inheriting const

Re: Is this documented behaviour?

2013-07-24 Thread John Colvin
On Wednesday, 24 July 2013 at 15:03:33 UTC, Dicebot wrote: On Tuesday, 23 July 2013 at 20:13:33 UTC, John Colvin wrote: To be honest, I wasn't expecting foo(*aptr) to compile at all, with a "taking address of temporary" error or similar. But there are no temporaries here. You seem to mix conce

Re: How to disable the DOS window at the start of my program on D

2013-07-24 Thread Adam D. Ruppe
On Wednesday, 24 July 2013 at 08:24:03 UTC, Rikki Cattermole wrote: Take a look at DLL def files. I believe from memory that they will help with that. Yeah, that or the linker flag. I talked about the .def file in this thread: http://forum.dlang.org/thread/xkvdpdsfzevanucrg...@forum.dlang.or

Re: Is this documented behaviour?

2013-07-24 Thread John Colvin
On Tuesday, 23 July 2013 at 16:34:54 UTC, John Colvin wrote: void foo(ref int a) { a = 5; } void main() { int a = 0; int* aptr = &a; foo(*aptr); assert(a == 5); a = 0; int b = *aptr; foo(b); assert

Re: Is this documented behaviour?

2013-07-24 Thread John Colvin
On Wednesday, 24 July 2013 at 14:52:53 UTC, monarch_dodra wrote: On Tuesday, 23 July 2013 at 20:13:33 UTC, John Colvin wrote: On Tuesday, 23 July 2013 at 17:06:37 UTC, Dicebot wrote: On Tuesday, 23 July 2013 at 17:03:52 UTC, John Colvin wrote: Sorry, I should have been more clear. It's the firs

Re: Is this documented behaviour?

2013-07-24 Thread Dicebot
On Tuesday, 23 July 2013 at 20:13:33 UTC, John Colvin wrote: To be honest, I wasn't expecting foo(*aptr) to compile at all, with a "taking address of temporary" error or similar. But there are no temporaries here. You seem to mix concepts of "temporary" and "stack variable with deterministic l

Re: Is this documented behaviour?

2013-07-24 Thread monarch_dodra
On Tuesday, 23 July 2013 at 20:13:33 UTC, John Colvin wrote: On Tuesday, 23 July 2013 at 17:06:37 UTC, Dicebot wrote: On Tuesday, 23 July 2013 at 17:03:52 UTC, John Colvin wrote: Sorry, I should have been more clear. It's the first case that seems weird to me. Why? '*aptr' is 'a' pretty much

Re: How to disable the DOS window at the start of my program on D

2013-07-24 Thread MGW
Thank you all. All ok!

Re: Auto keyword with const variable

2013-07-24 Thread Mike Parker
On Wednesday, 24 July 2013 at 08:07:55 UTC, Alex H wrote: This code: void test(const int n) { auto j = n; j++; } Gives this error: cannot modify const expression j Is this considered a feature or a bug? I would assume most people wouldn't want new variables inheriting const.

Re: How to disable the DOS window at the start of my program on D

2013-07-24 Thread Mike Parker
On Wednesday, 24 July 2013 at 10:20:08 UTC, Leandro Motta Barros wrote: For Win32/OPTLINK, I passed the following flag to dmd in a lil' project of mine: -L/SUBSYSTEM:WINDOWS:4.0 Worked for me. Yes, this is the way to do it. But if you're going to specify a subsystem version number, I bel

Re: Auto keyword with const variable

2013-07-24 Thread Artur Skawina
On 07/24/13 12:54, monarch_dodra wrote: > On Wednesday, 24 July 2013 at 10:37:40 UTC, Artur Skawina wrote: >> On 07/24/13 12:09, monarch_dodra wrote: >>> Keeping it to "same type, 100% of the time" seems like the best. >> >> No, it's a design bug. The head qualifier(s) should always be stripped >>

Re: Auto keyword with const variable

2013-07-24 Thread monarch_dodra
On Wednesday, 24 July 2013 at 10:37:40 UTC, Artur Skawina wrote: On 07/24/13 12:09, monarch_dodra wrote: Keeping it to "same type, 100% of the time" seems like the best. No, it's a design bug. The head qualifier(s) should always be stripped when copying objects. Stripping is always fine (ie

Re: Auto keyword with const variable

2013-07-24 Thread Artur Skawina
On 07/24/13 12:09, monarch_dodra wrote: > Keeping it to "same type, 100% of the time" seems like the best. No, it's a design bug. The head qualifier(s) should always be stripped when copying objects. Stripping is always fine (ie safe), not doing it just creates other problems, like the one in OP,

Re: How to disable the DOS window at the start of my program on D

2013-07-24 Thread Leandro Motta Barros
For Win32/OPTLINK, I passed the following flag to dmd in a lil' project of mine: -L/SUBSYSTEM:WINDOWS:4.0 Worked for me. LMB On Wed, Jul 24, 2013 at 5:24 AM, Rikki Cattermole wrote: > On Wednesday, 24 July 2013 at 08:16:39 UTC, MGW wrote: >> >> On Wednesday, 24 July 2013 at 08:08:19 UTC,

Re: Auto keyword with const variable

2013-07-24 Thread monarch_dodra
On Wednesday, 24 July 2013 at 10:01:14 UTC, bearophile wrote: dennis luehring: and how would it look to preserve the const if auto would auto-rip it of? You could write: immutable j = n; For every default behavour you need a way to implement the other nicely :-) Currently for the problem

Re: Auto keyword with const variable

2013-07-24 Thread bearophile
dennis luehring: and how would it look to preserve the const if auto would auto-rip it of? You could write: immutable j = n; For every default behavour you need a way to implement the other nicely :-) Currently for the problem of the OP you can use this: Unqual!(typeof(n)) j = n; Bye, b

Re: Auto keyword with const variable

2013-07-24 Thread dennis luehring
Am 24.07.2013 11:39, schrieb bearophile: Alex H: void test(const int n) { auto j = n; j++; } Gives this error: cannot modify const expression j Is this considered a feature or a bug? I would assume most people wouldn't want new variables inheriting const. It's a bit annoyin

Re: Auto keyword with const variable

2013-07-24 Thread MGW
On Wednesday, 24 July 2013 at 08:07:55 UTC, Alex H wrote: This code: void test(const int n) { auto j = n; j++; } Gives this error: cannot modify const expression j Is this considered a feature or a bug? I would assume most people wouldn't want new variables inheriting const.

Re: Auto keyword with const variable

2013-07-24 Thread bearophile
Alex H: void test(const int n) { auto j = n; j++; } Gives this error: cannot modify const expression j Is this considered a feature or a bug? I would assume most people wouldn't want new variables inheriting const. It's a bit annoying. I don't remember people discussing thi

Re: How to disable the DOS window at the start of my program on D

2013-07-24 Thread Rikki Cattermole
On Wednesday, 24 July 2013 at 08:16:39 UTC, MGW wrote: On Wednesday, 24 July 2013 at 08:08:19 UTC, Rikki Cattermole wrote: version(Windows) { import core.sys.windows.windows : FreeConsole; FreeConsole(); } DOS window flashes at the start, and that's bad. Take a look at DLL def files. I

Re: How to disable the DOS window at the start of my program on D

2013-07-24 Thread MGW
On Wednesday, 24 July 2013 at 08:08:19 UTC, Rikki Cattermole wrote: version(Windows) { import core.sys.windows.windows : FreeConsole; FreeConsole(); } DOS window flashes at the start, and that's bad.

Auto keyword with const variable

2013-07-24 Thread Alex H
This code: void test(const int n) { auto j = n; j++; } Gives this error: cannot modify const expression j Is this considered a feature or a bug? I would assume most people wouldn't want new variables inheriting const.

Re: How to disable the DOS window at the start of my program on D

2013-07-24 Thread Rikki Cattermole
On Wednesday, 24 July 2013 at 07:00:35 UTC, MGW wrote: I work with Qt from D and I do not need the DOS window. How to turn it off. Generally speaking to disable the console window on Windows by using code only something along these lines will work. version(Windows) { import core.sys.wind

How to disable the DOS window at the start of my program on D

2013-07-24 Thread MGW
I work with Qt from D and I do not need the DOS window. How to turn it off.