Discussion on Go and D
Manu
turkeyman at gmail.com
Mon Apr 9 02:03:09 PDT 2012
On 9 April 2012 04:09, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> On 4/9/12, Manu <turkeyman at gmail.com> wrote:
> > I don't follow. Can you give an example that shows this insecurity?
>
> I mean escaping references to locals:
>
> ref int xref;
> void foo() {
> int x;
> xref = x;
> }
>
> or
>
> ref int foo() {
> int x;
> ref int xref = x;
> return xref;
> }
>
> I mean a ref would basically be a pointer with some syntax sugar, no?
> It would have the same drawbacks as a pointer.
>
Nobody returns a ref to a local from a function, and the compiler can
easily warn about that.
Sure, but that's all this was ever meant to be right? alias as a sugar to
simplify long expressions... except alias is unsafe too, but in a different
and more subtle way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120409/aa8f6e0a/attachment.html>
More information about the Digitalmars-d
mailing list