Should out/ref parameters require the caller to specify out/ref like in C#?
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 29 07:45:38 PDT 2017
On Monday, 29 May 2017 at 08:40:27 UTC, ketmar wrote:
> yet i must say that using pointers in a code where they should
> be references makes me... nervous. it just doesn't feel right.
> but meh, i'll trade that (and safety, 'cause `&` is unsafe) for
> "call site ref indicator".
So one win with dip1000 is it allows it:
---
@safe void foo(scope int* a) {}
@safe void bar() {
int a;
foo(&a);
}
---
$ dmd ppp -c
ppp.d(4): Error: cannot take address of local a in @safe function
bar
But with dip 1000:
$ dmd ppp -dip1000 -c
# success!
Of course, dip1000 breaks the living crap out of just about
everything else (though all the errors are in phobos....) but it
is semi-sane in this case.
More information about the Digitalmars-d
mailing list