scope for array parameters
Jonathan M Davis
jmdavisProg at gmx.com
Tue Sep 4 13:25:39 PDT 2012
On Tuesday, September 04, 2012 22:19:55 Benjamin Thaut wrote:
> Am 04.09.2012 22:18, schrieb Alex Rønne Petersen:
> > On 04-09-2012 22:13, Benjamin Thaut wrote:
> > This is already what scope does today. See http://dlang.org/function.html:
> >
> > "references in the parameter cannot be escaped (e.g. assigned to a
> > global variable)"
> >
> > It's just that the compiler doesn't actually enforce it fully.
>
> Does the compiler already use this information to optimize array literals?
It had better not (I doubt that it does though). Unless scope is actually
properly enforced, then you're going to have major bugs if you use scope and
then escape references to that data anyway. And without the compiler checks,
that _will_ happen (especially when some folks use in all over the place).
Once scope is properly enforced, then optimizing based on it would be great,
but until it is, it's a _bad_ idea.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list