On 01/14/2013 06:52 PM, bearophile wrote:
Maybe this thread shows the need for some design work, see the comments
by Hara:
http://d.puremagic.com/issues/show_bug.cgi?id=8695
What's the meaning of "in" function arguments? What are the purposes of
"scope" for function arguments that contain indirections, and how to
implement that?
Bye,
bearophile
'in' is 'const scope'.
'scope' is supposed to restrict escaping references, but it is not
entirely clear what that means, and how to make it powerful enough. Eg.
what if part of a structure can be freely escaped, such as the contents
of an array of Objects, but not the array itself? I'd argue that
indirections in parameters should not be covered by 'scope', because it
is not something that is transitive. (the opposite would be)
Furthermore, there is the issue of how to treat 'ref' parameters.
Also, we may want to use 'scope' to annotate struct fields in some way,
so that structs can capture scope parameters that are ensured at the
call site to live at least as long as the struct instance.
An implementiation should use flow (and maybe lifetime) analysis.