DIP1000: Scoped Pointers

poliklosio via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Aug 11 14:12:28 PDT 2016


On Wednesday, 10 August 2016 at 20:35:23 UTC, Dicebot wrote:
> The first DIP has just landed into the new queue. It is a (...)

The wording is unclear in the section "Implicit Conversion of 
Function Pointers and Delegates".

It says "scope can be added to parameters, but not removed."

The trouble is that the word "added" can be understood in two 
opposite ways.

When you assign an address to a pointer variable, you can say 
that:

- you are assigning a new runtime value, so you are adding scope 
of parameter of the right hand side to the otherwise unscoped 
parameter of the left hand side, e.g.

alias T function(T) fp_t;
T bar(scope T);
fp_t   fp = &bar;   // Ok

- you are converting to a new variable, so you are adding scope 
of param of the left hand side to an otherwise unscoped param of 
the right hand side, e.g.

alias T function(scope T) fps_t;
T foo(T);
fps_t  fp = &foo;   // Error


Half-jokingly, I think its good to recognize that there is an 
ambiguity before multiple authors implement things with different 
assumptions and have a month-long discussion on github. :)

More seriously, this wording may make its way to documentation 
after the design is implemented.

If wording is fixed, I suggest also checking if all examples are 
correct.


More information about the Digitalmars-d-announce mailing list