[Dlang-internal] DIP1000 discussion and testing

Dicebot via Dlang-internal dlang-internal at puremagic.com
Sat Oct 22 15:36:05 PDT 2016


On 10/21/2016 09:43 PM, meppl wrote:
> On Friday, 21 October 2016 at 15:38:39 UTC, Dicebot wrote:
>>
>> 2) The whole thing is very disappointing ...
>> ... won't allow easy skipping of reference count inc/dec - ...
> 
> Isn't that - in the short term - impossible anyway? If a struct leaves
> the scope the reference counter has to be increased. But how does
> compiled code of a library know, if the foreign struct is an RC-object -
> without doing any runtime checks? So, any function has to exist twice,
> one time for RC and one time for no-RC?
> I mean, it's probably a big topic that doesn't have to be solved in that
> DIP, too.

It would be possible with even most simple borrowing semantics, see
http://forum.dlang.org/post/nu00tf$u0a$1@digitalmars.com - if one can
bind lifetime of a scope pointer to lifetime of stack variable, it
becomes OK to implicitly convert reference counted struct to scope
pointer for passing to other functions. So you only define function
taking scope pointer if it doesn't store it (and it works with both RC
and other data sourceS) or taking RC pointer explicitly if does indeed
store it.

But with the system Walter is proposing it is indeed impossible.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/dlang-internal/attachments/20161023/ff112acc/attachment.sig>


More information about the Dlang-internal mailing list