Re: cast(immutable) vs extra variable

2013-09-23 Thread Ali Çehreli
On 09/23/2013 06:34 AM, Daniel Davidson wrote: > I've stepped away from D for several months and just getting > back into it. > the first time at D Conf Actually, I've been thinking about you recently. My apologies for forgetting your last name. That's why I couldn't recognize you. :( > I wi

Re: cast(immutable) vs extra variable

2013-09-23 Thread Daniel Davidson
On Sunday, 22 September 2013 at 17:26:01 UTC, Ali Çehreli wrote: You are not alone. I tried to answer some of these questions in my DConf 2013 talk. I think I have only scratched the surface: http://dconf.org/talks/cehreli.html Ali Ali, thank you for providing great feedback and suggestion

Re: cast(immutable) vs extra variable

2013-09-22 Thread Ali Çehreli
On 09/19/2013 03:07 PM, Daniel Davidson wrote: > Here is a setup: Data is coming in - say over the wire or from a > database. It is very rich data with nestings of primitives, lists and > string keyed associative arrays, recursively - think nested json. Once > a data object is read in it is passe

Re: cast(immutable) vs extra variable

2013-09-19 Thread Daniel Davidson
On Thursday, 19 September 2013 at 20:05:34 UTC, Jonathan M Davis wrote: As soon as you have a const or immutable member in a struct, you can't ever assign anything to it, even if all of its other members are mutable (you could assign the individual, mutable members but not the whole struct). Th

Re: cast(immutable) vs extra variable

2013-09-19 Thread bearophile
Jonathan M Davis: All in all, I think that it's pretty much always a bad idea to have a struct with const or immutable members. It's just begging for problems. Tail-const or tail-immutable is fine, because the members themselves aren't const or immutable (just what they refer to), but having t

Re: cast(immutable) vs extra variable

2013-09-19 Thread Jonathan M Davis
On Thursday, September 19, 2013 18:47:12 Daniel Davidson wrote: > Multi-part question: > > 1) Why does the last line fail? If cast to immutable how is it > different than z? I know it is related to the ref. I'm using ref > because I think it is likely more efficient - so assume the > char[16] were

Re: cast(immutable) vs extra variable

2013-09-19 Thread Daniel Davidson
On Thursday, 19 September 2013 at 16:50:32 UTC, Namespace wrote: cast(immutable)data) is not an lvalue, it's a rvalue. ref accepts only lvalues. Thanks... about the other questions?

Re: cast(immutable) vs extra variable

2013-09-19 Thread Namespace
On Thursday, 19 September 2013 at 16:47:13 UTC, Daniel Davidson wrote: Multi-part question: 1) Why does the last line fail? If cast to immutable how is it different than z? I know it is related to the ref. I'm using ref because I think it is likely more efficient - so assume the char[16] were

cast(immutable) vs extra variable

2013-09-19 Thread Daniel Davidson
Multi-part question: 1) Why does the last line fail? If cast to immutable how is it different than z? I know it is related to the ref. I'm using ref because I think it is likely more efficient - so assume the char[16] were really char[1024]. 2) If I got rid of the ref, how many copies of the