@live questions

IGotD- nise at nise.com
Mon Nov 23 11:17:50 UTC 2020

On Sunday, 22 November 2020 at 07:22:22 UTC, Walter Bright wrote:
> Turning @live on by default would be brutal :-)

If you take this example.

struct MyStruct
	int s;

MyStruct*[string] nameLookup;
MyStruct*[int] idLookup;

@live void addStruct(scope MyStruct* s, const string name, int id)
	nameLookup[name] = s;
	idLookup[id] = s;

void main()
	MyStruct* s = new MyStruct;

	addStruct(s, "id1", 1);

In the presentation you basically did a copy of the single 
ownership in Rust. In the function we assign nameLookup and 
idLookup with a borrowed pointer but not as owners. This 
currently compiles but your presentation I get the impression 
that you are going to put D under full single ownership lockdown. 
If I would remove the scope for the s parameter in addStruct then 
it would emit an error when trying to assign to idLookup as s is 
already consumed by nameLookup.

More information about the Digitalmars-d mailing list