bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatially move from $n (was: C++11 move semantics)


From: Hans Åberg
Subject: Re: Automatially move from $n (was: C++11 move semantics)
Date: Tue, 18 Sep 2018 00:08:23 +0200

> On 17 Sep 2018, at 23:27, Frank Heckenbach <address@hidden> wrote:
> 
> Hans Åberg wrote:
> 
>>>> This illustrates the problem with make_pair($x, $x): one may try a
>>>> reference count or GC, but C++ does not support the implementation
>>>> of a GC, even though the compiler has the required information, it
>>>> is not accessible from the language.
>>> 
>>> Hold it! We were discussing a static compiler check, and within two
>>> paragraphs you divert to runtime checks (which are less reliable)
>>> and then to GC which I dislike for many reasons. To me it seems like
>>> a last effort: if you can't do proper resource management (like
>>> RAII), let the garbage collector pick up the pieces.
>> 
>> Yes, indeed C++ does not support that,
> 
> Are you replying to your own statement now? I never claimed (or
> cared) whether C++ supports GC.

C++ does not support the implementation of a (tracing) GC, because the 
information needed, though available to the compiler, is not available from the 
language. The fact that it does not have a GC is another topic.

>>> Fact is, I can
>>> do proper resource management in most cases, and just said it would
>>> be nice to have an extra check if it's not too hard to implement.
>> 
>> It looks is not hard to implement such a check against double
>> moves, and that might be the best solution, though it calls for
>> more careful runtime testing.
> 
> At runtime, yes. Basically an extended unique_ptr could detect this
> automatically.

This looks like becoming you option. You might use it for debugging only. By 
contrast, a reference count cannot be optimized away, so this might be better.

> I'd rather see a compile-time check, even if it's a
> bit primitive, i.e. gives false positives.

Even though the compiler may have access to the information to check that, you 
don't have access to that from the language itself. Parsing the language is a 
long haul, even though there were some here wanting help with that. There are 
LALR C++ grammars out there at least for some earlier language version.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]