On 12/14/2014 7:41 PM, Dicebot wrote:
On Monday, 15 December 2014 at 02:45:04 UTC, Walter Bright wrote:
1. All inout actually does is reduce code copy/pasta, it is not critical.

Being forced to duplicate every single function in two flavors to actually make
scope system usable? This is as much critical as it can be.

C++ seems to do fine without it for const. It's a convenience feature.


2. This is what scope inference is all about.

Which only works with templates and lack of scope on arguments does not affect
function body -> templates are not necessary, same as inout.

It also works with all the lambdas, since source for them is always available. I also wanted to make it (i.e. inference) work with auto functions, but Don Clugston was the primary objector :-)

I do view inference as something we need to extend to more functions.


2) at least optional transitivity to be able to express to protect with scope
data referenced by slice or owned linked list referenced from root node.

1. that won't work unless scope is a type constructor

I know and this is why I am leaning toward it being qualifier despite all
related issues.

That would be a truly massive change to D, and I'm not at all sure it would be worth it. We've (i.e. Kenji) have been fixing bugs with inout for years, and idea that had seemed straightforward.


2. it can be achieved by using wrappers that only allow by-scope references to
their data (RC is an example of such a wrapper)
It is viral approach and backwards incompatible one - we can't change signatures
of Phobos functions to return Wrapped!(char[]) instead of char[] for example.
While theoretically possible I can't call this approach practical - not until
see some convincing application example.

But you can change signatures to add annotations?

You're going to get one or the other.


This sounds totally against my understanding of scope. I want scope exactly to
prohibit such actions. However it is possible in slightly modified way - where
you don't directly insert pointer to AST but use public method of AST control
structure that checks if supplied scope pointer belongs to list of nodes it
owns  and casts away scope after that.

Wrappers do that, too.

I know that 'wrapper' sounds bad to you, but one of the goals of D's UDT's is to make it easy to adapt the behavior of a type by wrapping it in a struct, rather than build new behavior into the language.

Reply via email to