On 08/18/2016 05:20 AM, Johan Engelen wrote:

> `arr` is a global symbol that can be modified by code
> not seen by the compiler. So no assumptions can be made about the
> contents of arr.ptr and arr.length

Yet there is the following text in the spec:

* https://dlang.org/spec/statement.html#ForeachStatement

  "The aggregate must be loop invariant, meaning that elements to
   the aggregate cannot be added or removed from it in the
   NoScopeNonEmptyStatement."

I think the spirit of the spec includes other code outside of NoScopeNonEmptyStatement as well. If so, if elements are added to the array from other code (e.g. other threads) it should be a case of "all bets are off". So, I think both .ptr and .length could be cached.

Ali

Reply via email to