January 16, 2015
On 16.01.15 22:41, Andrei Alexandrescu wrote:
> Please help us work the kinks out! Walter will be proceeding with the
> opt-in implementation for quicker pipelining.
>
> http://wiki.dlang.org/DIP25
>
>
> Andrei

Why is it restricted to @safe?
January 16, 2015
On 1/16/15 6:10 PM, zeljkog wrote:
> On 16.01.15 22:41, Andrei Alexandrescu wrote:
>> Please help us work the kinks out! Walter will be proceeding with the
>> opt-in implementation for quicker pipelining.
>>
>> http://wiki.dlang.org/DIP25
>>
>>
>> Andrei
>
> Why is it restricted to @safe?

I don't think it is, the numerous @safe tags are superfluous. Andrei/Walter should clarify this...

-Steve
January 16, 2015
On 1/16/2015 2:13 PM, Steven Schveighoffer wrote:
> I can potentially see a situation like this:
>
> auto fun(T)(return ref T x)
>
> Where the auto deduces to something that couldn't possibly match T or any piece
> of it. Causing this function to error just because of a type mismatch is the
> wrong move.

That is addressed by the DIP, it is specifically allowed that a 'return ref' can be used even when the pointer cannot be coerced into the returned ref.

This is so that the 'return ref' can refer to a container that completely owns its contents, and this ownership can thus be transferred to the output.

January 16, 2015
On 1/16/2015 3:10 PM, zeljkog wrote:
> Why is it restricted to @safe?

Being a systems programming language, an escape from it may be necessary.
January 16, 2015
Walter Bright:

> On 1/16/2015 3:10 PM, zeljkog wrote:
>> Why is it restricted to @safe?
>
> Being a systems programming language, an escape from it may be necessary.

But this DIP to have a meaning should go with a "@safe by default", I think.

Bye,
bearophile
January 16, 2015
On Friday, 16 January 2015 at 21:41:25 UTC, Andrei Alexandrescu wrote:
> Please help us work the kinks out! Walter will be proceeding with the opt-in implementation for quicker pipelining.
>
> http://wiki.dlang.org/DIP25
>
>
> Andrei

I prefer the new syntax, this is a good change.

Is this DIP replacing DIP69?
January 16, 2015
On 1/16/15 6:25 PM, Walter Bright wrote:
> On 1/16/2015 3:10 PM, zeljkog wrote:
>> Why is it restricted to @safe?
>
> Being a systems programming language, an escape from it may be necessary.

So:

ref int foo(ref int x) { return x; }

is OK as long as it's not marked @safe? Is this made clear in the DIP? I didn't see that. In fact @safe is never mentioned except in the code examples. Even in the inline text examples, it's not mentioned.

In at least one place, it's implied that the above would not compile under the DIP: "With the proposed semantics, a function is disallowed to return a ref parameter of a part thereof UNLESS the parameter is also annotated with return."

-Steve
January 16, 2015
On 1/16/15 3:10 PM, zeljkog wrote:
> On 16.01.15 22:41, Andrei Alexandrescu wrote:
>> Please help us work the kinks out! Walter will be proceeding with the
>> opt-in implementation for quicker pipelining.
>>
>> http://wiki.dlang.org/DIP25
>>
>>
>> Andrei
>
> Why is it restricted to @safe?

To avoid some of the code breakage. -- Andrei
January 16, 2015
On 1/16/15 3:45 PM, weaselcat wrote:
> On Friday, 16 January 2015 at 21:41:25 UTC, Andrei Alexandrescu wrote:
>> Please help us work the kinks out! Walter will be proceeding with the
>> opt-in implementation for quicker pipelining.
>>
>> http://wiki.dlang.org/DIP25
>>
>>
>> Andrei
>
> I prefer the new syntax, this is a good change.
>
> Is this DIP replacing DIP69?

No, it's a gateway drug. -- Andrei
January 17, 2015
On 1/16/15 3:55 PM, Steven Schveighoffer wrote:
> On 1/16/15 6:25 PM, Walter Bright wrote:
>> On 1/16/2015 3:10 PM, zeljkog wrote:
>>> Why is it restricted to @safe?
>>
>> Being a systems programming language, an escape from it may be necessary.
>
> So:
>
> ref int foo(ref int x) { return x; }
>
> is OK as long as it's not marked @safe? Is this made clear in the DIP? I
> didn't see that. In fact @safe is never mentioned except in the code
> examples. Even in the inline text examples, it's not mentioned.
>
> In at least one place, it's implied that the above would not compile
> under the DIP: "With the proposed semantics, a function is disallowed to
> return a ref parameter of a part thereof UNLESS the parameter is also
> annotated with return."
>
> -Steve

The DIP applies to @safe code only for now. Steve, could you please add a clarifying section. Thanks! -- Andrei