with(auto x = ...)
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 26 07:49:39 PDT 2015
On 07/26/2015 01:04 PM, Idan Arye wrote:
> On Sunday, 26 July 2015 at 07:28:45 UTC, Kapps wrote:
>> On Friday, 24 July 2015 at 15:01:29 UTC, Adam D. Ruppe wrote:
>>> [...]
>>
>> The with statement is one where I think it would be interesting to
>> make it an expression.
>>
>> For named parameters (admittedly, I find this one a bit ugly):
>> foo(with(ParameterTypeTuple!foo) {
>> abc = 2,
>> def = 3
>> });
>>
>> Or just:
>> auto args = with(ParameterTypeTuple!foo) {
>> abc = 2,
>> def = 3
>> };
>> foo(args);
>>
>>
>> For initialization:
>> auto a = with(new FooBar()) {
>> name = "Foo",
>> bar = 3
>> };
>>
>> Or:
>> with(new Thread(&foo) {
>> isDaemon = true
>> }).start();
>
> Sadly it'll break all the code that currently use it, since we'll now
> need to terminate it with a semicolon.
Well, no. That does not follow. We can have both a with statement and a
with expression.
More information about the Digitalmars-d
mailing list