valid uses of shared

Artur Skawina art.08.09 at gmail.com
Mon Jun 11 08:42:26 PDT 2012


On 06/11/12 16:57, Steven Schveighoffer wrote:
> On Mon, 11 Jun 2012 09:39:40 -0400, Artur Skawina <art.08.09 at gmail.com> wrote:
> 
>> On 06/11/12 14:07, Steven Schveighoffer wrote:
>>> However, allocating another heap block to do sharing, in my opinion, is worth the extra cost.  This way, you have clearly separated what is shared and what isn't.
>>>
>>> You can always cast to get around the limitations.
>>
>> "clearly separating what is shared and what isn't" *is* exactly what
>> tagging the data with 'shared' does.
> 
> 
> I posted a response, it showed up in the online forums, but for some reason didn't show up in my nntp client...
> 
> If you missed it, it is here.
> 
> http://forum.dlang.org/post/op.wfqtz5u0eav7ka@steves-laptop

The mailing list delivered it too.

I'm against disallowing things that are not unsafe as such and have valid
use cases, so we will probably not agree about that.

I considered the GC/mempool implications before arguing for allowing 'shared'
fields inside unshared aggregates - the compiler has enough knowledge to pick
the right pool, if it ever decides to treat "local" data differently. I'm not
sure doing that would be good idea, in cases where the lifetime of an object
cannot be determined statically. But deciding to use a global pool can always
be done by checking if a shared field exists.

artur


More information about the Digitalmars-d mailing list