Re: A few questions about safe concurrent programming assumptions

2013-10-06 Thread Nicholas Smith
Thanks Jonathon, these are the kinds of warnings I was looking for. There are _no_ guarantees of atomicity with shared. Yes, on some architectures, writing a word size might be atomic, but the language guarantees no such thing. I was looking narrowly at x86, which I *think* such a statement

A few questions about safe concurrent programming assumptions

2013-10-06 Thread Nicholas Smith
So I suppose shared is confusing to everyone else, too. :) I'll just wing it and fill my program with rare but devastating bugs ;)

A few questions about safe concurrent programming assumptions

2013-10-02 Thread Nicholas Smith
Hi there, I have a few questions about what is safe to assume when writing concurrent code in D with data sharing (as opposed to message passing). After doing a fair amount of reading, I'm still slightly hazy about what shared does and doesn't guarantee. Here is the only assumption I unders

Differences between '==' and 'is' beyond null and overloading

2013-04-16 Thread Nicholas Smith
Hello there, I was wondering what the differences are functionally and semantically between '==' and 'is' beyond the two points here and my interpretation below. Functionally: - You must use 'is' to check for a null reference. - 'is' cannot be overloaded, and it assesses reference types based

Re: Strict definition of value types and reference types

2013-04-13 Thread Nicholas Smith
On Sunday, 14 April 2013 at 02:51:35 UTC, bearophile wrote: slices are kind of hybrids between values and references. You can also think of them as fat references. When you program in D you must remember this nature of sliced, otherwise your code will not work... Bye, bearophile Ali Çehreli

Re: Strict definition of value types and reference types

2013-04-13 Thread Nicholas Smith
Re-wording my last paragraph because of incorrect wording: In essence, don't all variables act as structs, with different operator overloads to give different semantics? If so, how do we classify 'value type' versus 'reference type'? What if I have a struct whose members are a fixed-length arr

Strict definition of value types and reference types

2013-04-13 Thread Nicholas Smith
Two things that I can't seem to nail down a strict definition for are value types and reference types. I know very well their basic definitions: a variable of a value type holds its own data and assignment copies the data, and a variable of a reference type holds a pointer to its data and assig

Re: Differing semantics between multidimensional fixed-length array and slice initialization

2013-04-01 Thread Nicholas Smith
Ali, thanks for the justification. It makes enough sense, and at least int[][](2, 3) matches the order in which you access the elements. I agree with Bearophile though that the syntax is very messy when you're mixing array types and pre/postfix declarations. If you weren't shooting for C fami

Differing semantics between multidimensional fixed-length array and slice initialization

2013-03-31 Thread Nicholas Smith
Hello there, So I noticed something about the semantics of multidimensional fixed-length array vs slice initialization: Code: int[2][3] array; writeln(array.length, " ", array[0].length); int[][] slice = new int[][](2, 3); writeln(slice.length, " ", slice[0].length); Output: 3 2 2 3 So it