More radical ideas about gc and reference counting

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon May 12 05:15:43 PDT 2014


On 05/12/2014 10:54 AM, Walter Bright wrote:
> On 5/11/2014 10:57 PM, Marco Leise wrote:
>> Am Sun, 11 May 2014 17:50:25 -0700
>> schrieb Walter Bright <newshound2 at digitalmars.com>:
>>
>>> As long as those pointers don't escape. Am I right in that one cannot
>>> store a
>>> borrowed pointer into a global data structure?
>>
>> Right, and that's the point and entirely positive-to-do™.
>
> This means that a global data structure in Rust has to decide what
> memory allocation scheme its contents must use,

Global variables are banned in Rust code outside of unsafe blocks.

> and cannot (without tagging) mix memory allocation schemes.
> ...

Tagging won't help with all memory allocation schemes.

> For example, let's say a compiler has internally a single hash table of
> strings. With a GC, those strings can be statically allocated, or on the
> GC heap, or anything with a lifetime longer than the table's.
> But I don't see how this could work in Rust.
>

It's possible if you don't make the table global.
(OTOH in D this is not going to work at all.)


More information about the Digitalmars-d mailing list