borrowed pointers vs ref
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 14 03:02:20 PDT 2014
On 5/14/2014 12:29 AM, Idan Arye wrote:
> On Tuesday, 13 May 2014 at 17:44:02 UTC, Walter Bright wrote:
>> On 5/13/2014 6:50 AM, Dicebot wrote:
>>> Walter's initial post implies that he wanted to re-used `ref` for borrowed
>>> pointer (which would mean same semantics as `scope` parameter qualifier)
>>
>> 'ref' already is to much extent, for example:
>>
>> @safe int foo(ref int x) {
>> auto a = &x;
>> return 3;
>> }
>>
>> dmd foo -c
>> foo.d(4): Error: cannot take address of parameter x in @safe function foo
>
> This has nothing to do with `ref`. If you remove the `ref` you get the exact
> same error.
Right, but the thing is, the only address of a local/parameter you can take is
by ref, not &.
More information about the Digitalmars-d
mailing list