New slides about Go

Max Samukha spambox at d-coding.com
Fri Oct 15 03:49:37 PDT 2010


On 10/15/2010 12:32 PM, Walter Bright wrote:
>
> The example relies on taking the address of a ref in a safe function. To
> close this hole, it appears that should be disallowed.

And disallowing it makes references not so useful.

What I like about Go's solution is that it is consistent with closures. 
When a group of locals escape with a closure (that is when the address 
of the local function using that group is taken) they are copied to 
heap. When a local escape by ref (that is when the address of the local 
is taken), it is also copied to heap.

What I don't like about Go's closures/addresses-to-locals and D's 
delegates is that stuff is heap-allocated implicitly and by default. Go 
has even gone (sorry) as far as allocating copies *every* time the 
address of a local is taken.

That reminds me of the argument about "new" being necessary for classes 
because it makes the heap allocation explicit. It is difficult to say 
good-bye to "new" but at the same time we are somehow happy with 
implicitly allocated closures.


More information about the Digitalmars-d mailing list