"with" should be deprecated with extreme prejudice
Ary Borenszweig
ary at esperanto.org.ar
Mon May 18 10:25:07 PDT 2009
Robert Fraser wrote:
> Nick Sabalausky wrote:
>> "BCS" <none at anon.com> wrote in message
>> news:a6268ff5f5d8cba54f824da454 at news.digitalmars.com...
>>> Hello Nick,
>>>
>>>> I'm not a touch-typer, but I've never seen much of a point to "with".
>>>> If I have to access a bunch of members of
>>>> "foo.member.x.bar[17].fizzle", I'll just do "auto fizz =
>>>> foo.member.x.bar[17].fizzle;" and use that, or put it into
>>> that dosn't work if it's by value and is used as an Lvalue.
>>>
>>>> a function that takes a "typeof(fizze)", or do something else along
>>> like this? that looks... odd.
>>>
>>> void outer()
>>> {
>>> void inner(ref T t)
>>> {
>>> t.somthing;
>>> ...
>>> }
>>> inner(foo.member.x.bar[17].fizzle);
>>> }
>>>
>>>> those lines. I've yet to come across a case where something like
>>>> that isn't perfectly sufficient.
>>>>
>>
>> Like I said, "or something along those lines". It all depends on the
>> specific code. I just haven't ever had any specific case where I felt
>> like I needed "with".
>
> I mainly use it for initialization of things:
>
> static S opCall(_x, _y)
> {
> S s;
> with(s)
> {
> x = _x;
> y = _y;
> happiness = null;
> }
> return s;
> }
Because of that, C# added the following syntax:
new S {
x = _x,
y = _y,
};
And I think that could replace "with" with no problem, because most of
the time (or all of the time) you use it when initializing an object.
More information about the Digitalmars-d
mailing list