On 04/30/2012 04:21 AM, H. S. Teoh wrote:
On Sun, Apr 29, 2012 at 01:46:25AM -0700, Jonathan M Davis wrote:
On Sunday, April 29, 2012 10:37:10 Timon Gehr wrote:
Well, what if the programmer "knows" that foo does not change 'aa',
but it actually does? Then there would possibly be a segmentation
fault.  This implies that the 'in' operator cannot be used in @safe
code. (Or there would have to be a special case, that allows 'in' if
the result is directly cast to bool.)

It's exactly as safe as any iterator or range which could be
invalidated - both of which can occur in safe code. Any of those could
blow up in entertaining ways if you use them after they've been
invalidated.

Pointers are considered safe. It's pointer arithmetic which isn't.
[...]

I get that this discussion is about what type 'in' should return, but
taking a step back, isn't it all moot because you could just use the
.get() method?


T


The AA might actually contain the provided default value, so 'get' is not always a good match.

Reply via email to