On Wed, 22 Sep 2010 21:48:19 -0400, Robert Jacques <sandf...@jhu.edu> wrote:

On Wed, 22 Sep 2010 13:10:36 -0400, Steven Schveighoffer <schvei...@yahoo.com> wrote:

On Wed, 22 Sep 2010 12:00:16 -0400, Robert Jacques <sandf...@jhu.edu> wrote:
What about value types?

Value types are implicitly convertable to immutable, so they can be strongly-pure.

No their not. Remember, arrays and other structs are value types in the type system. Logically, they may be reference types, but as far as their type signature goes, they are value types.

Arrays are not value types. A value type is one that contains no references, no matter how deep. It is irrelevant if you have to spell out the references or not.

another example of something that is not a value type:

alias int * iptr;

foo(iptr p);

iptr is not a value type just because you don't see any * in the signature.


But the compiler will be able to tell. I think adding a __traits(isStronglyPure, symbol) will be good for those rare occasions where you really want to ensure purity.

static assert(__traits(isStronglyPure, foo));

-Steve

This would work, but it wouldn't be self-documenting, etc.

Hm... OK, well I disagree, it looks like it's documented to me. I don't see a difference between tagging something as strongly pure and putting in the static assert (except verbosity of course). I will note that I think the above would be a rare situation.

-Steve

Reply via email to