Tuple DIP
Exil
Exil at gmall.com
Mon Jun 3 18:34:47 UTC 2019
On Monday, 3 June 2019 at 17:43:36 UTC, Timon Gehr wrote:
> On 20.09.18 19:08, Guillaume Boucher wrote:
>> On Saturday, 13 January 2018 at 18:28:55 UTC, Timon Gehr wrote:
>>> However, this proposal is independent of all the other ones,
>>> so in the end it is up to Walter and Andrei.
>>
>> Have there been any discussions regarding the semantics of _?
>>
>> struct G { ~this() { writeln("destruct"); } }
>> void main() {
>> auto _ = G();
>> writeln("here");
>> }
>>
>> The DIP currently says this should print first "here" and then
>> "destruct".
>>
>> However, as you cannot access the variable later, you most
>> often want to discard the data right away, i.e. print first
>> "destruct" and then "here".
>>
>> I personally find the second interpretation more useful.
>>
>
> This has not been discussed, but I agree it should be addressed
> somehow. The main issue is that right now "_" is a valid
> identifier.
Not sure what the use case is for this, but if you don't need the
value of the variable, assuming from a function or otherwise. You
can just not assign it to anything.
struct G { ~this() { writeln("destruct"); } }
void main() {
G(); // prints "destruct" before "here"
writeln("here");
}
definitely don't like the idea of changing how scope works. I'd
rather not the compiler choose to decide whether it does
something one way or another like that.
More information about the Digitalmars-d
mailing list