Re: Problem with taking inout, const references

2014-03-27 Thread Uranuz
Posted bugreport. https://d.puremagic.com/issues/show_bug.cgi?id=12478

Re: Problem with taking inout, const references

2014-03-26 Thread Ali Çehreli
On 03/26/2014 10:29 PM, Uranuz wrote: I haven't send a bug so I'm not familiar with it. How could I do it? Go to https://d.puremagic.com/issues/ Click "File an Issue" (but you may need to "Open a New Account" first). Product: D Component: DMD Version: D2 Importance: P3 normal A descriptiv

Re: Problem with taking inout, const references

2014-03-26 Thread Uranuz
Type is a compile-time concept; there is no difference between the compiled mutable versus const versions of your inout function. So, there is no need for more than one compilation. Yes. It's my mistake. For CPU there is only data (that are sequence of bits) and comands (that are sequence of

Re: Problem with taking inout, const references

2014-03-26 Thread Ali Çehreli
On 03/26/2014 12:17 PM, Uranuz wrote: > I modified this with casting pointer to pointer to *inout* and it > compiles then. > > inout(Cookie)* opBinaryRight(string op)(string name) inout if(op == "in") > {foreach( ref inout(Cookie) c; _cookies ) > if( c.name == name ) > r

Re: Problem with taking inout, const references

2014-03-26 Thread Uranuz
I modified this with casting pointer to pointer to *inout* and it compiles then. inout(Cookie)* opBinaryRight(string op)(string name) inout if(op == "in") { foreach( ref inout(Cookie) c; _cookies ) if( c.name == name ) return cast(inout(Cookie)*) &

Re: Problem with taking inout, const references

2014-03-26 Thread Ali Çehreli
On 03/26/2014 01:21 AM, Uranuz wrote: > If inout is treated as const does it mean that in this operator I can't > assign new value to cookie object. I have not investigated the compiler code but the following is very logical to me. inout is not a template mechanism. The code gets compiled onc

Re: Problem with taking inout, const references

2014-03-26 Thread Kagamin
On Tuesday, 25 March 2014 at 19:20:10 UTC, Uranuz wrote: In this case I don't understand sense of it. Also I have strange feelings about shared, because it's not widely used in code that I'm experienced to see and lacks of good usage examples. shared is used for low-level multithreading, if y

Re: Problem with taking inout, const references

2014-03-26 Thread Uranuz
If inout is treated as const does it mean that in this operator I can't assign new value to cookie object. In this case it means that I still should make separate class method with the same body to woraround this. I think that it's a bug. Am I right? void opIndexAssign(string value, s

Re: Problem with taking inout, const references

2014-03-26 Thread Uranuz
Source of error is that I have also the following methods inside ResponseCookise class: void opIndexAssign(string value, string name) { auto cookie = name in this; if( cookie is null ) _cookies ~= Cookie(name, value);

Re: Problem with taking inout, const references

2014-03-26 Thread Uranuz
Still compiles for me. Could you please show us a minimal main() as well. Thank you, Ali Yes. This exact piece of code compiles in 2.064, but it doesn't compile in my project. I don't know how to localize the problem yet. It's very strange. I have tried to create class instance with differen

Re: Problem with taking inout, const references

2014-03-25 Thread Ali Çehreli
On 03/25/2014 02:01 PM, Uranuz wrote: >> Your code compiles with the development branch of dmd. What version >> are you using? >> > Now I'm using 2.064. Still compiles for me. Could you please show us a minimal main() as well. Thank you, Ali

Re: Problem with taking inout, const references

2014-03-25 Thread Uranuz
Your code compiles with the development branch of dmd. What version are you using? Now I'm using 2.064. May be this bug is already fixed. In 2.065 I experience problem that std.json library module is not compatible with code written for previous versions. This is why I returned to 2.064. As f

Re: Problem with taking inout, const references

2014-03-25 Thread Ali Çehreli
On 03/25/2014 12:20 PM, Uranuz wrote: > I have problem with understanding of work of modifiers const, inout, > immutable modifiers. I am sure you know these as well, but here is my quick list: const: "I shall not modify data" immutable: "I demand immutable data" inout: "Whatever the actual type

Problem with taking inout, const references

2014-03-25 Thread Uranuz
I have problem with understanding of work of modifiers const, inout, immutable modifiers. As I understand inout keyword is intended to consume const, immutable and data without modifiers. It's how I expect it to work otherwise I don't understand what is the purpose of inout. In current implemen