[Dlang-internal] DIP1000 discussion and testing

Martin Nowak via Dlang-internal dlang-internal at puremagic.com
Thu Oct 20 19:57:12 PDT 2016


On Thursday, 20 October 2016 at 21:36:44 UTC, Walter Bright wrote:
> On 10/20/2016 12:27 PM, Dicebot wrote:
>   int* bar()
>   {
>     int p;
>     return foo1(&p);
>   }

This is a problem I had reading DIP1000. At first it decomposes 
language constructs into primitives then sets up rules for the 
primitives.
Such a mathematical approach is nice, but it isn't exercised 
throughout the DIP.

For example the most interesting function semantics just refer 
"See section dedicated to discussing methods.", but the Function 
section 
(https://github.com/dlang/DIPs/blob/6f9f50ee579bd0ccc11e5dfeef035cbbb095e0d9/DIPs/DIP1000.md#functions) doesn't contain formal lifetime rules for functions.
Weirdly the Pointer section 
(https://github.com/dlang/DIPs/blob/6f9f50ee579bd0ccc11e5dfeef035cbbb095e0d9/DIPs/DIP1000.md#pointers) seems to contain lifetime rules for function return values.
At this point the DIP regresses a bit into showing examples with 
short notes whether they are errors or correct.
It's somewhat difficult to extract a mental model from that.

The DIP seems to define the lifetime of function return values as 
the longest lifetime that can be conservatively assumed given the 
function arguments.

You mentioned an article and a talk, do you have any cleaner/more 
detailed explanation for functions @Walter?


More information about the Dlang-internal mailing list