On Fri, 24 Sep 2010 10:47:16 -0400, Steven Schveighoffer <schvei...@yahoo.com> wrote:

On Fri, 24 Sep 2010 10:33:10 -0400, Robert Jacques <sandf...@jhu.edu> wrote:

On Fri, 24 Sep 2010 09:32:40 -0400, Steven Schveighoffer <schvei...@yahoo.com> wrote:
structs can have value copy semantics. But for a struct that contains a reference, the references have reference semantics, which makes the struct a reference type.

A struct is never a reference type. It may have reference semantics, but this is a high-order feature that is uncheckable by the compiler. At best the compiler can detect that a struct contains references, not how those references are exposed/managed by the API.

Containing references means it cannot be cast to immutable, the only important thing when determining the strength of purity here.

This whole discussion is going nowhere, you haven't made any real points. Can you think of a case where the compiler would be wrong in determining purity strength for "value types" as you define them? An example would be most helpful.

-Steve

I feel like I've upset you and would like to make amends. First, this discussion was never about the compiler being able to determine purity. That's easy. The point raised was about whether the programmer could enforce strong-purity for any strongly-pure fucntion. The answer is that you can by making all arguments immutable, which is a fairly minor restriction on the callee. Second, this thread (fiber?), has veered a little off-topic due to a misunderstanding/debate about value-types vs value-semantics and reference-types vs reference-semantics. Perhaps it's because I work with large, 'hybrid' structs a lot, but the difference between value-type and value-semantics is very large in my mind. Third, this fiber started, in part, due to a question by regarding value-types being answered with value-semantics. Forth, I raised the question regarding value-types in part due to half-remembered old posts in which value-semantics were discussed but under the label of value-types, thus causing confusion in my brain. And because it was late at night, I decided to ask a simple question instead of testing DMD's current behavior myself. I did end up testing DMD the next day (and then banging my head on a wall), but by then all this had started.

Reply via email to